Skip to content

Commit 40008b2

Browse files
ameteratierian
authored andcommitted
chore: add GitHub Actions to kick-off release and block manual creation of PRs to the release branch (#1821)
1 parent 36f8901 commit 40008b2

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Blocks PRs targeting the release branch that are not created by the release GHA workflow.
2+
#
3+
# This works because workflows cannot trigger other workflows unless they call them directly.
4+
# As a result, this workflow will only run with a PR targeting release is manually created.
5+
#
6+
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
7+
8+
name: Block Manual PR to Release
9+
10+
on:
11+
pull_request:
12+
branches:
13+
- release
14+
15+
permissions:
16+
pull-requests: write
17+
18+
jobs:
19+
check:
20+
name: Block Manual PR to Release
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
25+
26+
- name: Close PR
27+
shell: bash
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
PR_NUMBER: ${{ github.event.pull_request.number }}
31+
run: |
32+
gh pr close $PR_NUMBER --comment "Invalid PR! PRs targeting the release branch must be created by the GHA release workflow."
33+
exit 1

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Creates a PR to push main to release branch to kick-off the CircleCI release workflow
2+
name: Release Amplify iOS
3+
4+
on:
5+
workflow_dispatch:
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: macos-latest
14+
15+
steps:
16+
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
17+
18+
- name: Create PR to push main to release branch
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
run: "gh pr create --title 'chore: kickoff release' --body 'kickoff release' --head main --base release"

0 commit comments

Comments
 (0)