generated from ni/github-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (59 loc) · 2.08 KB
/
reusable-workflow.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
# .github/workflows/reusable-workflow.yml
name: Reusable Build
on:
workflow_call:
inputs:
working-folder:
required: true
type: string
scripts-folder:
required: true
type: string
secrets:
GITHUB_TOKEN:
required: true
jobs:
build-and-test:
runs-on: [self-hosted, iconeditor]
env:
RelativePath: ${{ inputs.working-folder }}
RelativePathScripts: ${{ inputs.scripts-folder }}
steps:
# Same steps you have now, except you read from the 'inputs'
# rather than your vars.AgentWorkingFolder, etc.
- name: Checkout code
uses: actions/checkout@v3
- name: Get Build Revision
id: get_revision
shell: bash
run: |
...
# Use $GITHUB_ENV instead of ::set-output (since set-output is deprecated).
# E.g.:
# echo "build_revision=$new_build_revision" >> $GITHUB_ENV
- name: Set agent into development mode
shell: pwsh
working-directory: ${{ env.RelativePathScripts }}
run: |
.\Set_Development_Mode.ps1 -RelativePath "${{ env.RelativePath }}"
- name: Test and Build
shell: pwsh
working-directory: ${{ env.RelativePathScripts }}
env:
build_id: ${{ env.build_id }}
build_revision: ${{ env.build_revision }}
build_version: ${{ env.build_version }}
run: |
.\Build.ps1 -RelativePath "${{ env.RelativePath }}" `
-AbsolutePathScripts "${{ env.RelativePathScripts }}"
- name: Restore agent from development mode
shell: pwsh
working-directory: ${{ env.RelativePathScripts }}
run: |
.\RevertDevelopmentMode.ps1 -RelativePath "${{ env.RelativePath }}"
- name: Commit and Push Build Counter
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Increment build revision to ${{ env.build_revision }}'
file_pattern: '.github/buildCounter.txt'