Skip to content

Commit b43b619

Browse files
committed
Add test case for workflow failure on nothing to commit
1 parent af931f6 commit b43b619

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

.github/workflows/test-tag.yml

+30-14
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,11 @@ name: Run tests, Tag release
33
on:
44
push:
55
branches:
6-
# explicit deny all here to make sure there isnt a commit loop
7-
- '!*'
86
- main
97
- fix/*
108

119
jobs:
12-
create_tag:
13-
runs-on: ubuntu-latest
14-
if: github.ref == 'refs/heads/main'
15-
needs: run_tests
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v2
19-
20-
- name: check if tag already exists
21-
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* && git rev-parse "$(cat VERSION)" >/dev/null 2>&1 && exit 1 || exit 0
2210

23-
- name: create tag
24-
run: git config --global user.email "${{ github.actor }}" && git config --global user.name "${{ github.actor }}" && git tag -a -m "$(cat VERSION)" $(cat VERSION) && git push --follow-tags
2511
run_tests:
2612
runs-on: ubuntu-latest
2713
steps:
@@ -98,3 +84,33 @@ jobs:
9884
destination_branch: commit_message_test
9985
deploy_key: ${{ secrets.DEPLOY_KEY }}
10086
commit_message: testing a custom commit message (${{ github.sha }})
87+
88+
89+
# Test that fails on nothing to commit - a copy of the previous test
90+
- name: test issue where workflow fails when there is nothing to commit
91+
uses: ./
92+
with:
93+
source: tmp.txt
94+
destination_repo: leigholiver/commit-with-deploy-key
95+
destination_branch: commit_message_test
96+
deploy_key: ${{ secrets.DEPLOY_KEY }}
97+
commit_message: testing a custom commit message (${{ github.sha }})
98+
99+
# Test that nothing to commit is OK
100+
101+
102+
103+
# If the tests are successful, and we've merged to main, create a tag
104+
create_tag:
105+
runs-on: ubuntu-latest
106+
if: github.ref == 'refs/heads/main'
107+
needs: run_tests
108+
steps:
109+
- name: Checkout
110+
uses: actions/checkout@v2
111+
112+
- name: check if tag already exists
113+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* && git rev-parse "$(cat VERSION)" >/dev/null 2>&1 && exit 1 || exit 0
114+
115+
- name: create tag
116+
run: git config --global user.email "${{ github.actor }}" && git config --global user.name "${{ github.actor }}" && git tag -a -m "$(cat VERSION)" $(cat VERSION) && git push --follow-tags

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.0.2
1+
v1.0.3

0 commit comments

Comments
 (0)