-
Notifications
You must be signed in to change notification settings - Fork 637
Add release pr workflow #1192
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
base: master
Are you sure you want to change the base?
Add release pr workflow #1192
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,92 @@ | ||||||
| --- | ||||||
| # This workflow is triggered via repository_dispatch from the | ||||||
| # build-and-release workflow in backup-utils-private. It copies | ||||||
| # docs and README.md from backup-utils-private to a release dev branch | ||||||
| # in backup-utils, then creates a PR using GITHUB_TOKEN so that the | ||||||
| # PR author is github-actions[bot]. This allows the app token in | ||||||
| # backup-utils-private to approve the PR as a different actor. | ||||||
| name: Create Release PR | ||||||
|
|
||||||
| on: | ||||||
| repository_dispatch: | ||||||
| types: [create-release-pr] | ||||||
|
|
||||||
| permissions: | ||||||
| contents: write | ||||||
| pull-requests: write | ||||||
|
|
||||||
| jobs: | ||||||
| create-release-pr: | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - uses: actions/create-github-app-token@v1 | ||||||
| id: app-token | ||||||
| with: | ||||||
| app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} | ||||||
| private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} | ||||||
| owner: ${{ github.repository_owner }} | ||||||
| repositories: "backup-utils-private" | ||||||
|
|
||||||
| - name: Checkout backup-utils | ||||||
| uses: actions/checkout@v5 | ||||||
|
|
||||||
| - name: Checkout backup-utils-private | ||||||
| uses: actions/checkout@v5 | ||||||
| with: | ||||||
| token: ${{ steps.app-token.outputs.token }} | ||||||
| repository: github/backup-utils-private | ||||||
| path: './backup-utils-private' | ||||||
|
|
||||||
| - name: Replace docs directory with backup-utils-private docs | ||||||
| run: | | ||||||
| rm -rf docs | ||||||
| cp -r backup-utils-private/docs docs | ||||||
|
|
||||||
| - name: Replace README.md with backup-utils-private README.md | ||||||
| run: | | ||||||
| rm README.md | ||||||
| cp backup-utils-private/README.md README.md | ||||||
|
|
||||||
| - name: Delete backup-utils-private | ||||||
| run: | | ||||||
| rm -rf backup-utils-private | ||||||
|
|
||||||
| - name: Create release branch commit | ||||||
| run: | | ||||||
| version="${{ github.event.client_payload.version }}" | ||||||
| branch="release/$version" | ||||||
|
Comment on lines
+56
to
+57
|
||||||
| git config user.name "github-actions[bot]" | ||||||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||||||
| git checkout -B "$branch" | ||||||
| git add docs README.md | ||||||
| git commit --allow-empty -m "$version release" | ||||||
| git push --force-with-lease --set-upstream origin "$branch" | ||||||
|
Comment on lines
+61
to
+63
|
||||||
|
|
||||||
| - name: Create or find release pull request | ||||||
| id: release-pr | ||||||
| env: | ||||||
| GH_TOKEN: ${{ github.token }} | ||||||
| run: | | ||||||
| version="${{ github.event.client_payload.version }}" | ||||||
| branch="release/$version" | ||||||
| pr_number="$(gh pr list --head "$branch" --base master --json number --jq '.[0].number')" | ||||||
|
||||||
| pr_number="$(gh pr list --head "$branch" --base master --json number --jq '.[0].number')" | |
| pr_number="$(gh pr list --head "$branch" --base master --json number --jq '.[0].number // empty')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow uses
${{ github.repository_owner }}when minting the GitHub App token, but hardcodesrepository: github/backup-utils-privatefor the checkout. Using the same owner variable for the checkout target avoids drift if the repo is ever moved or this workflow is reused elsewhere.