Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust prod release flow to support release branch lookup #737

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading