Skip to content

Create Tag Cron

Create Tag Cron #179

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: Build and Test code
id: builder
if: steps.checker.outputs.commits > 0
run: |
npm ci
npm run build
npm run test
- name: Bump version and create tag
if: steps.checker.outputs.commits > 0
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
MAIN_BRANCH: main
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
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;