-
Notifications
You must be signed in to change notification settings - Fork 72
122 lines (99 loc) · 2.4 KB
/
update.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
112
113
114
115
116
117
118
119
120
121
122
---
name: "AzOps - Update"
on:
#
# Workflow Dispatch
# Manually invoke the Update action via the GitHub
# UI on-demand. This is to avoid any potential conflicts
# with user changes to the workflows.
#
workflow_dispatch:
env:
#
# Branch Name
#
# Default: update
#
branch: "update"
jobs:
update:
#
# Update
#
name: "Update"
runs-on: ubuntu-20.04
steps:
#
# Checkout
# Checks-out the repository
# Repo: origin
#
- name: "Checkout"
uses: actions/checkout@v4
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
fetch-depth: 0
path: 'origin'
#
# Checkout
# Checks-out the repository
# Repo: upstream
#
- name: "Checkout"
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: 'Azure/AzOps-Accelerator'
fetch-depth: 0
path: 'upstream'
#
# Configure
# Set global options
#
- name: "Configure"
working-directory: 'origin'
shell: bash
run: |
git config user.name 'github-actions'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
#
# Copy
# Update the workflow files
#
- name: "Copy"
shell: bash
run: |
test -f ./origin/.github/workflows/patch.yml && rm -f ./origin/.github/workflows/patch.yml
cp -R -v ./upstream/.github/workflows/ ./origin/.github/
cp -R -v ./upstream/.github/actions/ ./origin/.github/
#
# Commit
# Record changes to the repository
#
- name: "Commit"
id: commit
working-directory: 'origin'
shell: bash
run: |
DIFF=$(git diff --name-only)
echo $DIFF
if [ -n "$DIFF" ]
then
git checkout -b ${{ env.branch }}
git add .github/
git commit -m 'Update commit'
git push origin ${{ env.branch }} -f
echo "state=continue" >> $GITHUB_OUTPUT
fi
#
# Merge
# Automatically merge the head branch into base
#
- name: "Merge"
if: steps.commit.outputs.state == 'continue'
working-directory: 'origin'
shell: bash
run: |
gh pr create --base 'main' --head ${{ env.branch }} --title 'GitHub Actions' --body 'New workflow version available from the upstream repository.'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}