Skip to content

Create update dockerfiles PR #6259

Create update dockerfiles PR

Create update dockerfiles PR #6259

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"