Skip to content

Create Tag Cron

Create Tag Cron #183

name: Create Tag Cron
on:
schedule:
- cron: '0 18 * * 1'
# For Testing
# push: { branches: [main] }
jobs:
tag-if-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
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 "::set-output name=commits::${COUNT}"
- 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: steps.checker.outputs.commits > 0
run: |
npm ci
npm run build
npm run test
COUNT=$(git status | grep -o modified | wc -l)
echo "::set-output name=modified::${COUNT}"
- 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;