-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (62 loc) · 2.61 KB
/
internal-environment-variables-reference-documentation.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
name: Generate environment variables reference documentation
on:
push:
branches:
- main
paths:
- '**/*.sh' # Only run when script files changed
- '.github/workflows/environment-internal-variables-reference-documentation.yml' # or when this file was changed
pull_request:
branches:
- main
paths:
- '**/*.sh' # Only run when script files changed
- '.github/workflows/environment-internal-variables-reference-documentation.yml' # or when this file was changed
jobs:
reports:
runs-on: ubuntu-latest
env:
CI_COMMIT_MESSAGE: Automated environment variables documentation generation (CI)
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
steps:
- name: Checkout git repository
uses: actions/checkout@v4
with:
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
- name: Generate environment variables reference document
working-directory: scripts
run: |
./documentation/generateEnvironmentVariableReference.sh
- name: Use git to detect changes in the regenerated document and set generated_document_changed
run: git diff --quiet || echo "generated_document_changed=true" >> $GITHUB_ENV
- name: Display generated_document_changed
run: echo "generated_document_changed=${{ env.generated_document_changed}}"
- name: Archive generated environment variables reference document
if: env.generated_document_changed
uses: actions/upload-artifact@v4
with:
name: environment-variables-reference-document
path: ./scripts/ENVIRONMENT_VARIABLES.md
if-no-files-found: error
retention-days: 5
- name: Commit generated environment variables reference document if there were changes
# Only run when a pull request gets merged or a commit is pushed to the main branch.
# And only run when the generated document changed to avoid an empty commit or an error while committing.
if: github.event_name == 'push' && env.generated_document_changed
run: |
set -x
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
git config --global user.email "[email protected]"
git fetch origin
git status
git add ./scripts/ENVIRONMENT_VARIABLES.md
git status
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
git status
git rebase --strategy-option=theirs origin/main --verbose
git status
git add ./scripts/ENVIRONMENT_VARIABLES.md
git status
git commit --amend --no-edit
git status
git push --verbose