-
Notifications
You must be signed in to change notification settings - Fork 11
124 lines (118 loc) · 4.35 KB
/
workflow.yml
File metadata and controls
124 lines (118 loc) · 4.35 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs: # https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action
Version: ${{ steps.gitversion.outputs.MajorMinorPatch }}
CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 #fetch-depth is needed for GitVersion
#Install and calculate the new version with GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.1.0
with:
versionSpec: 6.x
- name: Determine Version
uses: gittools/actions/gitversion/execute@v4.1.0
id: gitversion # step id used as reference for output values
- name: Display GitVersion outputs
run: |
echo "Version: ${{ steps.gitversion.outputs.MajorMinorPatch }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}"
# checkout the code from this branch, and then test the action from here
test:
runs-on: ubuntu-latest
steps:
- name: checkout the code from this branch
uses: actions/checkout@v5
with:
ref: ${{ github.ref }}
#basic tests
- name: Test this repo
uses: ./ # the ./ runs the action.yml in this repo
with:
workflows: 'CI'
- name: Test another repo with all arguments
uses: ./
with:
workflows: 'CI/CD'
owner-repo: 'DeveloperMetrics/DevOpsMetrics'
default-branch: 'main'
number-of-days: 30
- name: Test no workflow
uses: ./
with:
workflows: ''
owner-repo: 'samsmithnz/GitHubToAzureDevOps'
#authenication tests
- name: Test elite repo with PAT Token
uses: ./
with:
workflows: 'Feature Flags CI/CD'
owner-repo: 'samsmithnz/SamsFeatureFlags'
pat-token: "${{ secrets.PATTOKEN }}"
- name: Test elite repo, multiple workflows, with PAT Token
uses: ./
with:
workflows: 'Feature Flags CI/CD,CodeQL'
owner-repo: 'samsmithnz/SamsFeatureFlags'
pat-token: "${{ secrets.PATTOKEN }}"
- name: Test elite repo with PAT Token with invalid TOKEN
uses: ./
with:
workflows: 'Feature Flags CI/CD'
owner-repo: 'samsmithnz/SamsFeatureFlags'
pat-token: "INVALIDPATTOKEN"
- name: Test unknown repo
uses: DeveloperMetrics/deployment-frequency@main
with:
workflows: 'CI/CD'
owner-repo: 'samsmithnz/SamsFeatureFlags2'
- name: Test this repo with GitHub Actions Token
uses: ./
with:
workflows: 'CI'
actions-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Test this repo with GitHub App Token
uses: ./
with:
workflows: 'CI'
app-id: "${{ secrets.APPID }}"
app-install-id: "${{ secrets.APPINSTALLID }}"
app-private-key: "${{ secrets.APPPRIVATEKEY }}"
- name: Test elite repo with GitHub App Token
uses: ./
with:
workflows: 'Feature Flags CI/CD'
owner-repo: 'samsmithnz/SamsFeatureFlags'
app-id: "${{ secrets.APPID }}"
app-install-id: "${{ secrets.APPINSTALLID }}"
app-private-key: "${{ secrets.APPPRIVATEKEY }}"
releaseAction:
runs-on: ubuntu-latest
needs:
- build
- test
if: github.ref == 'refs/heads/main'
steps:
- name: Display GitVersion outputs
run: |
echo "Version: ${{ needs.build.outputs.Version }}"
echo "CommitsSinceVersionSource: ${{ needs.build.outputs.CommitsSinceVersionSource }}"
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: needs.build.outputs.CommitsSinceVersionSource > 0 #Only create a release if there has been a commit/version change
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: "v${{ needs.build.outputs.Version }}"
release_name: "v${{ needs.build.outputs.Version }}"