forked from redhat-developer/rhdh-plugin-export-overlays
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish-release-branch-workspace-plugins.yaml
More file actions
88 lines (75 loc) · 3.13 KB
/
Copy pathpublish-release-branch-workspace-plugins.yaml
File metadata and controls
88 lines (75 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Publish RHDH Release Dynamic Plugin Images
on:
workflow_call:
concurrency:
group: ${{ github.workflow_ref }}-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
name: Prepare
outputs:
last-published-commit: ${{ steps.get-last-published-commit.outputs.last-published-commit }}
steps:
- name: Get last published commit
id: get-last-published-commit
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
INPUT_RELEASE_BRANCH: ${{ github.ref_name }}
with:
script: |
core.info(`Getting latest commit on branch ${core.getInput('release_branch')}`);
const currentRun = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
const workflowId = currentRun.data.workflow_id;
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflowId,
branch: core.getInput('release_branch'),
status: 'success',
per_page: 10,
exclude_pull_requests: true,
});
for (const run of runs.data.workflow_runs) {
if (context.payload.commits.some(c => c.id === run.head_sha)) {
core.info(`Skipping run ${run.id} for commit ${run.head_sha}, it's part of the push`);
continue;
}
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id,
filter: 'latest',
});
const exportJobs = jobs.data.jobs.filter(j => j.name.startsWith('export /'));
if (exportJobs.length > 0 && exportJobs.every(j => j.conclusion === 'success')) {
core.info(`Last published commit to compare with: ${run.head_sha}`);
core.setOutput('last-published-commit', run.head_sha);
return;
}
core.info(`Skipping run ${run.id} for commit ${run.head_sha}: export jobs not all successful`);
}
core.info('Last published commit not found');
core.setOutput('last-published-commit', '');
export:
uses: redhat-developer/rhdh-plugin-export-utils/.github/workflows/export-workspaces-as-dynamic.yaml@main
needs:
- prepare
with:
publish-container: true
image-repository-prefix: ${{ format('ghcr.io/{0}', github.repository) }}
last-publish-commit: ${{ needs.prepare.outputs.last-published-commit }}
# use empty prefix so that we will prepend bs_1.yy.z__ instead of next__
image-tag-prefix: ${{ '' }}
image-registry-user: ${{ github.actor }}
secrets:
image-registry-password: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
attestations: write
packages: write
id-token: write