-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,77 @@ | ||
name: Create Release Tag | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
types: | ||
- closed | ||
|
||
jobs: | ||
create-tag: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Sync node version and setup cache | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- name: Git checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
token: ${{ secrets.CI_TOKEN }} | ||
|
||
- name: create and push tag | ||
- name: Sync node version and setup cache | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- name: GITHUB CONTEXT | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
- name: Get commit message | ||
run: | | ||
COMMIT_MESSAGE=$(git log --format=%B -n 1) | ||
echo "$COMMIT_MESSAGE" | ||
echo "commitmsg=${COMMIT_MESSAGE}" >> $GITHUB_ENV | ||
- name: Git Identity | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
- name: Set Current Version | ||
if: startsWith( env.commitmsg , 'chore(release):' ) | ||
shell: bash -ex {0} | ||
run: | | ||
CURRENT_VERSION=$(node -p 'require("./package.json").version') | ||
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV | ||
- name: Tag Check | ||
if: startsWith( env.commitmsg , 'chore(release):' ) | ||
id: tag_check | ||
shell: bash -ex {0} | ||
run: | | ||
git --version | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "<>" | ||
git tag "v$(node -e "console.log(require('./package.json').version)")" | ||
git log --oneline --graph | ||
git push --tags | ||
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}" | ||
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \ | ||
-H "Authorization: token ${GITHUB_TOKEN}") | ||
if [ "$http_status_code" -ne "404" ] ; then | ||
echo "::set-output name=exists_tag::true" | ||
else | ||
echo "::set-output name=exists_tag::false" | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Git Tag | ||
if: startsWith( env.commitmsg , 'chore(release):' ) && steps.tag_check.outputs.exists_tag == 'false' | ||
uses: azu/action-package-version-to-git-tag@v1 | ||
with: | ||
version: ${{ env.CURRENT_VERSION }} | ||
github_token: ${{ secrets.CI_TOKEN }} | ||
github_repo: ${{ github.repository }} | ||
git_commit_sha: ${{ github.sha }} | ||
git_tag_prefix: "test-v" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters