Update lifecycle #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update lifecycle | |
on: | |
schedule: | |
# Every Monday at 8am UTC. | |
- cron: '0 8 * * MON' | |
workflow_dispatch: | |
jobs: | |
update-lifecycle: | |
name: Update lifecycle | |
runs-on: pub-hk-ubuntu-22.04-small | |
steps: | |
- name: Get token for GH application (Linguist) | |
uses: heroku/use-app-token-action@main | |
id: generate-token | |
with: | |
app_id: ${{ vars.LINGUIST_GH_APP_ID }} | |
private_key: ${{ secrets.LINGUIST_GH_PRIVATE_KEY }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# We always want the version bump and resultant PR to target main, not the branch of the workflow_dispatch. | |
ref: main | |
token: ${{ steps.generate-token.outputs.app_token }} | |
- name: Record existing lifecycle version | |
id: existing-version | |
# Having to use grep instead of yq due to: | |
# https://github.com/mikefarah/yq/issues/1758 | |
run: echo "version=$(grep --perl-regexp --null-data --only-matching '\[lifecycle\]\nversion = "\K([^"]+)' builder-22/builder.toml)" >> "${GITHUB_OUTPUT}" | |
- name: Determine latest lifecycle version | |
id: latest-version | |
run: echo "version=$(gh release view --repo buildpacks/lifecycle --json tagName --jq '.tagName | sub("v"; "")')" >> "${GITHUB_OUTPUT}" | |
env: | |
GH_TOKEN: ${{ steps.generate-token.outputs.app_token }} | |
- name: Update builder manifests with latest lifecycle version | |
# This only updates manifests that were on the same version as builder-22, to ensure | |
# that any legacy builder images pinned to older lifecycle versions are not updated too. | |
run: sed --in-place --expression 's/^version = "${{ steps.existing-version.outputs.version }}"$/version = "${{ steps.latest-version.outputs.version }}"/' */builder.toml | |
# Note: This step will skip creating a PR if there are no changes to commit. | |
- name: Create or update pull request | |
id: pr | |
uses: peter-evans/[email protected] | |
with: | |
token: ${{ steps.generate-token.outputs.app_token }} | |
title: Update lifecycle from v${{ steps.existing-version.outputs.version }} to v${{ steps.latest-version.outputs.version }} | |
body: | | |
Release notes: | |
https://github.com/buildpacks/lifecycle/releases/tag/v${{ steps.latest-version.outputs.version }} | |
Full changelog: | |
https://github.com/buildpacks/lifecycle/compare/v${{ steps.existing-version.outputs.version }}...v${{ steps.latest-version.outputs.version }} | |
commit-message: | | |
Update lifecycle from v${{ steps.existing-version.outputs.version }} to v${{ steps.latest-version.outputs.version }} | |
Release notes: | |
https://github.com/buildpacks/lifecycle/releases/tag/v${{ steps.latest-version.outputs.version }} | |
Full changelog: | |
https://github.com/buildpacks/lifecycle/compare/v${{ steps.existing-version.outputs.version }}...v${{ steps.latest-version.outputs.version }} | |
branch: update-lifecycle | |
delete-branch: true | |
committer: ${{ vars.LINGUIST_GH_APP_USERNAME }} <${{ vars.LINGUIST_GH_APP_EMAIL }}> | |
author: ${{ vars.LINGUIST_GH_APP_USERNAME }} <${{ vars.LINGUIST_GH_APP_EMAIL }}> | |
- name: Enable PR auto-merge | |
if: steps.pr.outputs.pull-request-operation == 'created' | |
run: gh pr merge --auto --squash "${{ steps.pr.outputs.pull-request-number }}" | |
env: | |
GH_TOKEN: ${{ steps.generate-token.outputs.app_token }} |