-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (49 loc) · 1.63 KB
/
tag_if_commits.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Create Tag Cron
on:
schedule:
- cron: '0 18 * * 1'
repository_dispatch:
types: [tag-if-commits]
# 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 "Files Modified: ${COUNT}"
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;