Create Tag Cron #180
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
name: Create Tag Cron | |
on: | |
schedule: | |
- cron: '0 18 * * 1' | |
repository_dispatch: | |
types: [tag-if-commits] | |
workflow_dispatch: | |
inputs: | |
release: | |
description: set to true in order to force taggin | |
required: false | |
type: boolean | |
jobs: | |
tag-if-commits: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Check if any commits since last release | |
id: checker | |
run: | | |
git fetch --prune --unshallow --tags | |
COUNT=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline | wc -l) | |
echo "commits=${COUNT}" >> $GITHUB_OUTPUT | |
- name: Configure Git | |
run: | | |
git config --global user.email "action@github.com" | |
git config --global user.name "GitHub Action" | |
- name: Build Action code | |
id: builder | |
if: ${{ inputs.release || steps.checker.outputs.commits > 0 }} | |
run: | | |
npm ci | |
npm run build | |
npm run test | |
COUNT=$(git status | grep -o modified | wc -l) | |
echo "Files Modified: ${COUNT}" | |
echo "modified=${COUNT}" >> $GITHUB_OUTPUT | |
- name: Commit Changes | |
if: steps.builder.outputs.modified > 0 | |
run: | | |
git add . | |
git commit -am "chore(action): update action build output" | |
- name: Bump version and create tag | |
if: steps.checker.outputs.commits > 0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }} | |
MAIN_BRANCH: main | |
run: | | |
npm run release | |
REMOTE_URL="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git push "${REMOTE_URL}" HEAD:${MAIN_BRANCH} --follow-tags --tags; |