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

Using Github App token to trigger CI for version increment PRs #116

Merged
merged 1 commit into from
Feb 19, 2022
Merged
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
14 changes: 12 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: GitHub App token
id: github_app_token
uses: tibdex/github-app-token@v1.5.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: 22958780

- uses: actions/checkout@v2
- name: Fetch Tag and Version Information
run: |
Expand All @@ -27,13 +33,17 @@ jobs:
- uses: actions/checkout@v2
with:
ref: ${{ env.BASE }}
token: ${{ steps.github_app_token.outputs.token }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, if we don't give the app token here, what things it could break, will it cause the new PR not triggering CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean for this specific step or overall for using the token?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not overall, just for this checkout action. If this checkout still use the default token, we only pass this app token to the next create PR action, will it cause the new PR not triggering CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have seen multiple recommendations from this GHA to use the same token in actions/checkout as well. One of them is peter-evans/create-pull-request#990


- name: Increment Version
run: |
echo Incrementing $CURRENT_VERSION to $NEXT_VERSION
sed -i "s/$CURRENT_VERSION-SNAPSHOT/$NEXT_VERSION-SNAPSHOT/g" build.gradle

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ steps.github_app_token.outputs.token }}
base: ${{ env.BASE }}
commit-message: Incremented version to ${{ env.NEXT_VERSION }}
delete-branch: true
Expand Down