Skip to content

Commit

Permalink
fix: adjust prod release flow to support release branch lookup (#737)
Browse files Browse the repository at this point in the history
Co-authored-by: afwilcox <alecwilcox@gmail.com>
  • Loading branch information
jon-funk and afwilcox authored Nov 7, 2024
1 parent 0bb98b4 commit 3ac1678
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
12 changes: 10 additions & 2 deletions .github/actions/get-latest-pr-number/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
token:
description: Specify token (GH or PAT), instead of inheriting one from the calling workflow
default: ${{ github.token }}
release_branch:
description: Specify the release branch to get the latest PR number from, like `release/myrelease`. Outside of PRs you need to manually provide this otherwise it will be an empty string.
default: ${{ github.pull_request.head.ref }}

outputs:
pr:
Expand All @@ -22,8 +25,13 @@ runs:
run: |
git fetch origin
release_branch="${{ github.event.pull_request.head.ref }}"
echo "Detected release branch: $release_branch"
release_branch="${{ inputs.release_branch }}"
echo "Configured release branch as: $release_branch"
if ! git show-ref --verify --quiet refs/remotes/origin/$release_branch; then
echo "Release branch $release_branch does not exist in the repository."
exit 1
fi
latest_pr=$(git log origin/$release_branch --pretty=format:'%s' | grep -oP '(?<=#)\d+' | head -n 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
name: Merge
name: Release To Production

on:
push:
branches: [main]
paths-ignore:
- "*.md"
- ".github/**"
- ".github/graphics/**"
- "!.github/workflows/**"
workflow_dispatch:
inputs:
pr_no:
description: "PR-numbered container set to deploy"
type: number
release_branch:
description: "Specify the release branch to get the latest PR number from, like `release/myrelease`"
required: true

concurrency:
Expand All @@ -28,10 +20,17 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- name: Verify Is Main Branch
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
run: |
echo "This workflow should not be triggered with workflow_dispatch on a branch other than main"
exit 1
- uses: actions/checkout@v4
- name: Get Latest PR Number in release branch
id: latest-pr
uses: ./.github/actions/get-latest-pr-number
with:
release_branch: ${{ github.event.inputs.release_branch }}
- name: Set PR Output
run: echo "pr=${{ steps.latest-pr.outputs.pr }}" >> $GITHUB_OUTPUT

Expand Down

0 comments on commit 3ac1678

Please sign in to comment.