feat: allow/disallow users to run workflows when pushing to a pull request from a fork (#9397)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9397
Reviewed-by: Lucas <sclu1034@noreply.codeberg.org>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
This commit is contained in:
Mathieu Fenniak 2025-11-09 01:40:29 +01:00
commit ce93a16557
52 changed files with 2822 additions and 287 deletions

View file

@ -397,6 +397,44 @@ test('historical attempt dropdown interactions', async () => {
expect(window.location.href).toEqual(toAbsoluteUrl('/user1/repo2/actions/runs/123/jobs/1/attempt/2'));
});
test('run approval interaction', async () => {
const pullRequestLink = '/example-org/example-repo/pulls/456';
const wrapper = mount(RepoActionView, {
props: {
...defaultTestProps,
initialJobData: {
state: {
run: {
canApprove: true,
status: 'waiting',
commit: {
pusher: {},
branch: {
link: toAbsoluteUrl(pullRequestLink),
},
},
},
currentJob: {
steps: [
{
summary: 'Test Job',
},
],
},
},
logs: {
stepsLog: [],
},
},
},
});
await flushPromises();
const approve = wrapper.findAll('button').filter((button) => button.text() === 'Locale Approve');
expect(approve.length).toEqual(1);
approve[0].trigger('click');
expect(window.location.href).toEqual(toAbsoluteUrl(`${pullRequestLink}#pull-request-trust-panel`));
});
test('artifacts download links', async () => {
Object.defineProperty(document.documentElement, 'lang', {value: 'en'});
vi.spyOn(global, 'fetch').mockImplementation((url, opts) => {

View file

@ -223,7 +223,8 @@ export default {
},
// approve a run
approveRun() {
POST(`${this.run.link}/approve`);
const url = `${this.run.commit.branch.link}#pull-request-trust-panel`;
window.location.href = url;
},
// show/hide the step logs for a group
toggleGroupLogs(event) {