-
Notifications
You must be signed in to change notification settings - Fork 135
67 lines (63 loc) · 2.18 KB
/
create-update-dockerfiles-PR.yml
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
name: Create update dockerfiles PR
on:
workflow_run:
workflows: [Update external base images, Update internal base images]
types: completed
workflow_dispatch:
jobs:
# ------------------------
get_branches:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.generate-matrix.outputs.branches }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Generate Matrix
id: generate-matrix
env:
GITHUB_TOKEN: ${{secrets.CONTENT_BOT_TOKEN}}
run: |
git fetch
branches=$(git branch -r | grep autoupdate/)
matrix="[ "
for branch in $(echo $branches); do
exists=`gh pr list --state open -H ${branch#origin/}`
if [ -z $exists ]; then
matrix="${matrix} \"${branch#origin/}\","
fi
done
matrix="${matrix%?}"
SERVICES="${matrix} ]"
echo ::set-output name=branches::${SERVICES}
pull-request:
if: ${{ needs.get_branches.outputs.branches != '[ ]' }}
runs-on: ubuntu-latest
needs:
- get_branches
strategy:
max-parallel: 2
fail-fast: false
matrix:
branches: ${{ fromJSON(needs.get_branches.outputs.branches) }}
steps:
- uses: actions/checkout@v2
- name: pull-request
id: open-pr
uses: repo-sync/pull-request@v2
with:
GITHUB_TOKEN: ${{secrets.CONTENT_BOT_TOKEN}}
source_branch: "${{ matrix.branches }}"
destination_branch: "" # If blank, default: master
pr_title: "build(dockerfiles) update Dockerfile - ${{ matrix.branches }}" # Title of pull request
pr_body: "This is automated PR to update dockerfiles base images\n${{ matrix.branches }}"
- name: approve and merge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ steps.open-pr.outputs.pr_url }}
if: ${{ steps.open-pr.outputs.pr_url }}
run: |
echo "Approving and merging"
gh pr review --approve "$PR_URL"
gh pr merge --auto --squash "$PR_URL"