-
Notifications
You must be signed in to change notification settings - Fork 2
111 lines (93 loc) · 3.56 KB
/
test-tag.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Run tests, Tag release
on:
push:
branches:
- main
- fix/*
jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: create test file
run: echo $(date) > tmp.txt
- name: create test directory
run: mkdir -p tmp && cp tmp.txt tmp && echo "second cool file" > tmp/tmp2.txt
- name: test with file
uses: ./
id: filetest
with:
source: tmp.txt
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: file_test
deploy_key: ${{ secrets.DEPLOY_KEY }}
- name: test commit hash output
run: echo "the commit hash for the file test is ${{ steps.filetest.outputs.commit_hash }}"
- name: test with directory
uses: ./
with:
source: tmp
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: directory_test
deploy_key: ${{ secrets.DEPLOY_KEY }}
- name: test destination directory
uses: ./
with:
source: tmp
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: destination_directory_test
destination_folder: destination
deploy_key: ${{ secrets.DEPLOY_KEY }}
- name: test destination subdirectory
uses: ./
with:
source: tmp
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: destination_subdirectory_test
destination_folder: destination/destination_sub
deploy_key: ${{ secrets.DEPLOY_KEY }}
- name: test destination directory with removal
uses: ./
with:
source: tmp
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: destination_directory_test_with_delete
delete_destination: true
deploy_key: ${{ secrets.DEPLOY_KEY }}
- name: test with different username
uses: ./
with:
source: tmp.txt
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: username_test
deploy_key: ${{ secrets.DEPLOY_KEY }}
git_username: some different user
- name: test with different commit message
uses: ./
with:
source: tmp.txt
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: commit_message_test
deploy_key: ${{ secrets.DEPLOY_KEY }}
commit_message: testing a custom commit message (${{ github.sha }})
- name: test workflow doesnt fail when there is nothing to commit
uses: ./
with:
source: tmp.txt
destination_repo: leigholiver/commit-with-deploy-key
destination_branch: commit_message_test
deploy_key: ${{ secrets.DEPLOY_KEY }}
commit_message: testing a custom commit message (${{ github.sha }})
# If the tests are successful, and we've merged to main, create a tag
create_tag:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: run_tests
steps:
- name: Checkout
uses: actions/checkout@v2
- name: check if tag already exists
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* && git rev-parse "$(cat VERSION)" >/dev/null 2>&1 && exit 1 || exit 0
- name: create tag
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