@@ -10,79 +10,5 @@ name: Upstream Sync Workflow
1010jobs :
1111 upstream-sync :
1212 runs-on : ubuntu-latest
13- env :
14- downstream-prefix : stackhpc
15- upstream-prefix : openstack:stable
1613 steps :
17- - name : Check if ${{ format('{0}/{1}', env.upstream-prefix, inputs.release-series) }} is ahead of ${{ format('{0}/{1}', env.downstream-prefix, inputs.release-series) }}
18- uses : actions/github-script@9ac08808f993958e9de277fe43a64532a609130e
19- id : check-if-ahead
20- with :
21- script : |
22- const { repo, owner } = context.repo;
23- const result = await github.rest.repos.compareCommits({
24- owner,
25- repo,
26- head: '${{ format('{0}/{1}', env.upstream-prefix, inputs.release-series) }}',
27- base: '${{ format('{0}/{1}', env.downstream-prefix, inputs.release-series) }}',
28- });
29- return result.data['ahead_by'] > 0 ? 'true' : 'false';
30- result-encoding : string
31- - name : Get upstream SHA
32- uses : actions/github-script@9ac08808f993958e9de277fe43a64532a609130e
33- id : get-upstream-sha
34- with :
35- script : |
36- if(${{ steps.check-if-ahead.outputs.result }} == true) {
37- const { repo, owner } = context.repo;
38- const result = await github.rest.repos.getCommit({
39- owner: '${{ format('openstack') }}',
40- repo: repo,
41- ref: '${{ format('{0}/{1}', 'stable', inputs.release-series) }}',
42- });
43- return result.data['sha'];
44- }
45- result-encoding : string
46- - name : Create copy of upstream branch
47- uses : actions/github-script@9ac08808f993958e9de277fe43a64532a609130e
48- id : branch-name
49- with :
50- script : |
51- if(${{ steps.check-if-ahead.outputs.result }} == true) {
52- const { repo, owner } = context.repo;
53- const date = new Date();
54- const prDate = `${date.getFullYear()}-${date.getMonth()}-${date.getDay()}`;
55- const branchName = '${{ format('upstream-{0}-', inputs.release-series) }}' + prDate;
56- const result = await github.rest.git.createRef({
57- owner,
58- repo,
59- ref: 'refs/heads/' + branchName,
60- sha: '${{ steps.get-upstream-sha.outputs.result }}',
61- });
62- return branchName;
63- }
64- result-encoding : string
65- - name : Create PR ${{ format('{0}/{1}', env.downstream-prefix, inputs.release-series) }} with ${{ steps.branch-name.outputs.result }}
66- uses : actions/github-script@9ac08808f993958e9de277fe43a64532a609130e
67- with :
68- script : |
69- if(${{ steps.check-if-ahead.outputs.result }} == true) {
70- const { repo, owner } = context.repo;
71- const result = await github.rest.pulls.create({
72- title: 'Synchronise ${{ inputs.release-series }} with ${{ steps.branch-name.outputs.result }}',
73- owner,
74- repo,
75- head: '${{ steps.branch-name.outputs.result }}',
76- base: '${{ format('{0}/{1}', env.downstream-prefix, inputs.release-series) }}',
77- maintainer_can_modify: false,
78- body: [
79- 'The changes from ${{ env.upstream-prefix }}/${{ inputs.release-series }} have been included in this automated PR'
80- ].join('\n')
81- });
82- github.rest.issues.addLabels({
83- owner,
84- repo,
85- issue_number: result.data.number,
86- labels: ['automated', 'sync']
87- });
88- }
14+ -
0 commit comments