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

update: release/2.2.1 to develop #15

Closed
wants to merge 2 commits into from
Closed
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
43 changes: 35 additions & 8 deletions .github/workflows/gitflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ on:
TOKEN:
description: 'GitHub token (Default: GitHub Action token)'
required: false
GITHUB_APP_ID:
description: 'GitHub app id for fetching GitHub token'
required: false
GITHUB_APP_PRIVATE_KEY:
description: 'GitHub app private key for fetching GitHub token'
required: false
GITHUB_APP_OWNER:
description: 'GitHub app owner for fetching GitHub token'
required: false

env:
MAIN_BRANCH: ${{ inputs.MAIN_BRANCH || 'main' }}
Expand All @@ -66,7 +75,10 @@ env:
VERSION_EXPRESSION: ${{ inputs.VERSION_EXPRESSION || '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*' }}
VERSION_HEADER: ${{ inputs.VERSION_HEADER || '## ' }}
CHANGELOG: ${{ inputs.CHANGELOG || 'changelog.md' }}
GITHUB_TOKEN: ${{ secrets.TOKEN || github.token }}
TOKEN: ${{ secrets.TOKEN || github.token }}
GITHUB_APP_ID: ${{ secrets.GITHUB_APP_ID }}
GITHUB_APP_PRIVATE_KEY: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
GITHUB_APP_OWNER: ${{ secrets.GITHUB_APP_OWNER }}
SOURCE_BRANCH: ${{ github.event.pull_request.head.ref }}
SOURCE_COMMIT: ${{ github.event.pull_request.head.sha }}
DESTINATION_BRANCH: ${{ github.event.pull_request.base.ref }}
Expand All @@ -76,6 +88,21 @@ jobs:
gitflow:
runs-on: ubuntu-latest
steps:
- name: Fetching GitHub Token
id: fetching-github-token
if: ${{ env.GITHUB_APP_ID && env.GITHUB_APP_PRIVATE_KEY && env.GITHUB_APP_OWNER }}
uses: actions/create-github-app-token@v1
with:
app-id: ${{ env.GITHUB_APP_ID }}
private-key: ${{ env.GITHUB_APP_PRIVATE_KEY }}
owner: ${{ env.GITHUB_APP_OWNER }}

- name: Using GitHub Token
if: ${{ env.GITHUB_APP_ID && env.GITHUB_APP_PRIVATE_KEY && env.GITHUB_APP_OWNER }}
run: |
echo '::add-mask::${{ steps.fetching-github-token.outputs.token }}'
echo 'TOKEN=${{ steps.fetching-github-token.outputs.token }}' >> $GITHUB_ENV

- name: Check branch
id: check-branch
run: |
Expand Down Expand Up @@ -155,12 +182,12 @@ jobs:
pull_number: context.issue.number,
state: 'closed',
})
github-token: ${{ env.GITHUB_TOKEN }}
github-token: ${{ env.TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ env.GITHUB_TOKEN }}
token: ${{ env.TOKEN }}

- name: Checkout commit
run: |
Expand Down Expand Up @@ -207,7 +234,7 @@ jobs:
pull_number: context.issue.number,
state: 'closed',
})
github-token: ${{ env.GITHUB_TOKEN }}
github-token: ${{ env.TOKEN }}

- name: If warn on check feature branch
if: always() && steps.check-feature-branch.outputs.warning != null
Expand All @@ -234,7 +261,7 @@ jobs:
repo: context.repo.repo,
body: message,
})
github-token: ${{ env.GITHUB_TOKEN }}
github-token: ${{ env.TOKEN }}

- name: Check release branch
id: check-release-branch
Expand Down Expand Up @@ -306,7 +333,7 @@ jobs:
pull_number: context.issue.number,
state: 'closed',
})
github-token: ${{ env.GITHUB_TOKEN }}
github-token: ${{ env.TOKEN }}

- name: Finish feature branch
id: finish-feature-branch
Expand Down Expand Up @@ -361,7 +388,7 @@ jobs:
&& git push origin --delete ${{ env.SOURCE_BRANCH }} \
|| :
env:
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
GH_TOKEN: ${{ env.TOKEN }}

- name: Finish norelease branch
id: finish-norelease-branch
Expand Down Expand Up @@ -390,4 +417,4 @@ jobs:
&& git push origin --delete ${{ env.SOURCE_BRANCH }} \
|| :
env:
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
GH_TOKEN: ${{ env.TOKEN }}
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 2.2.1

- fix: use TOKEN instead of GITHUB_TOKEN

## 2.2.0

- feature: support fetching github token from github app

## 2.1.2

- fix: solve issue that DEVELOP_BRANCH input is not used
Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ A implementation of workflows of GitHub Actions to support using gitflow on GitH
# VERSION_HEADER: ... # Default: '## '
# CHANGELOG: ... # Default: 'changelog.md'
# secrets:
# TOKEN: ... # Default: Github Action token
# GITHUB_TOKEN: ... # Default: GitHub Action token
# GITHUB_APP_ID: ... # Default: GitHub App ID for fetching GitHub token
# GITHUB_APP_PRIVATE_KEY: ... # Default: GitHub App ID for fetching GitHub token
# GITHUB_APP_OWNER: ... # Default: GitHub App ID for fetching GitHub token
```
4. Set `Workflow permissions` as checking `Read and write permissions` and `Allow GitHub Actions to create and approve pull requests`.
5. Do not check `Automatically delete head branches`.
Expand Down