Skip to content

.github/workflows/generate_buildpack_bump_pr.yml #68

.github/workflows/generate_buildpack_bump_pr.yml

.github/workflows/generate_buildpack_bump_pr.yml #68

on:
workflow_dispatch:
schedule:
- cron: "0 9 1 * *"
env:
GO_VERSION: "1.20"
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: [email protected]
GITHUB_UNPRIV_USERNAME: ${{ secrets.GOVUK_PAAS_UNPRIVILEGED_BOT_USERNAME }}
jobs:
generate-buildpack-bump-pr:
runs-on: ubuntu-latest
steps:
## Setup
- name: Checkout repo
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
submodules: true
# auth will be retained by repo configuration
token: ${{ secrets.GOVUK_PAAS_UNPRIVILEGED_BOT_PAT }}
- name: Install gettext
run: |
sudo apt install gettext
# for envsubst
- name: "Install Go ${{env.GO_VERSION}}"
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
with:
go-version: "${{env.GO_VERSION}}"
- name: "Install yq"
run: |
go install github.com/mikefarah/yq/v4@5ef537f3fd1a9437aa3ee44c32c6459a126efdc4 # v4.34.1
- name: generate-buildpacks-yml
run: |
./scripts/update_buildpacks.sh
- name: Commit and push
run: |
export NEW_BRANCH_NAME="auto-bump-buildpacks-$(date -u '+%Y%m%dT%H%M')"
export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
git remote add unpriv-fork "https://github.com/${GITHUB_UNPRIV_USERNAME}/paas-cf.git"
git checkout -b "$NEW_BRANCH_NAME"
git add config/buildpacks.yml
git add config/buildpacks.rolling.yml
git commit -m 'bump buildpacks'
git push unpriv-fork "$NEW_BRANCH_NAME"
echo "NEW_BRANCH_NAME=$NEW_BRANCH_NAME" >> $GITHUB_ENV
- name: Create PR
env:
GITHUB_TOKEN: ${{ secrets.GOVUK_PAAS_UNPRIVILEGED_BOT_PAT }}
run: |
FINAL_BODY=$(mktemp)
envsubst < ./.github/workflows/automatic_buildpack_bump_pr_body.md > $FINAL_BODY
gh pr create \
--base main \
--head "$GITHUB_UNPRIV_USERNAME:$NEW_BRANCH_NAME" \
--title "Buildpack upgrades, $(date -u '+%B %Y')" \
--body-file "$FINAL_BODY"