11---
2- name : Update Library Templates
3-
4- # yamllint disable-line rule:truthy
5- on :
6- schedule :
7- - cron : " 0 8 * * 1-5"
8- workflow_dispatch :
9- inputs :
10- enterprise-scale-repository-branch :
11- description : " The branch to target for the enterprise scale repository"
12- required : false
13- default : " main"
14-
15- env :
16- remote_repository : " Azure/Enterprise-Scale"
17- remote_repository_branch : ${{ github.event.inputs.enterprise-scale-repository-branch != 'main' && github.event.inputs.enterprise-scale-repository-branch || 'main' }}
18- branch_name : " patch-library-${{ github.run_number }}"
19- pr_title : " Update Library Templates (automated)"
20- pr_body :
21- " This is an automated 'pull_request' containing updates to the library templates stored in 'modules/archetypes/lib'.\n
22- Please review the 'files changed' tab to review changes."
23-
24- jobs :
25- update-templates :
26- name : Update Library Templates
27- runs-on : ubuntu-latest
28- permissions :
29- contents : write
30- pull-requests : write
31- steps :
32- - name : Local repository checkout
33- uses : actions/checkout@v4
34- with :
35- path : ${{ github.repository }}
36- fetch-depth : 0
37-
38- - name : Remote repository checkout
39- uses : actions/checkout@v4
40- with :
41- repository : ${{ env.remote_repository }}
42- path : ${{ env.remote_repository }}
43- ref : ${{ env.remote_repository_branch }}
44-
45- - uses : tibdex/github-app-token@v2
46- id : generate-token
47- with :
48- app_id : ${{ secrets.APP_ID }}
49- private_key : ${{ secrets.APP_PRIVATE_KEY }}
50-
51- - name : Configure local git
52- run : |
53- git config user.name github-actions
54- git config user.email [email protected] 55- working-directory : ${{ github.repository }}
56-
57- - name : Create and checkout branch
58- run : |
59- BRANCH_URL="repos/${{ github.repository }}/branches"
60- JQ_FILTER=".[] | select(.name == \"${{ env.branch_name }}\").name"
61- CHECK_BRANCH_ORIGIN=$(gh api $BRANCH_URL | jq -r "$JQ_FILTER")
62- if [ -z "$CHECK_BRANCH_ORIGIN" ]
63- then
64- echo "Checkout local branch (create new, no origin)..."
65- git checkout -b ${{ env.branch_name }}
66- else
67- echo "Checkout local branch (create new, track from origin)..."
68- git checkout -b ${{ env.branch_name }} --track origin/${{ env.branch_name }}
69- fi
70- working-directory : ${{ github.repository }}
71- env :
72- GITHUB_TOKEN : ${{ steps.generate-token.outputs.token }}
73-
74- - name : Update library templates
75- uses : azure/powershell@v2
76- with :
77- inlineScript : |
78- Write-Information "==> Running policy definitions script..." -InformationAction Continue
79- ${{ github.repository }}/.github/scripts/Invoke-LibraryUpdatePolicyDefinitions.ps1 `
80- -AlzToolsPath "${{ github.workspace }}/${{ env.remote_repository }}/src/Alz.Tools/" `
81- -TargetPath "${{ github.workspace }}/${{ github.repository }}" `
82- -SourcePath "${{ github.workspace }}/${{ env.remote_repository }}" `
83- -Reset
84-
85- Write-Information "==> Running policy assignments and archetypes script..." -InformationAction Continue
86- ${{ github.repository }}/.github/scripts/Invoke-LibraryUpdatePolicyAssignmentArchetypes.ps1 `
87- -AlzToolsPath "${{ github.workspace }}/${{ env.remote_repository }}/src/Alz.Tools/" `
88- -TargetPath "${{ github.workspace }}/${{ github.repository }}" `
89- -SourcePath "${{ github.workspace }}/${{ env.remote_repository }}"
90- azPSVersion : " latest"
91-
92- - name : Check for changes
93- id : git_status
94- run : |
95- mapfile -t "CHECK_GIT_STATUS" < <(git status -s)
96- printf "%s\n" "${CHECK_GIT_STATUS[@]}"
97- echo "changes=${#CHECK_GIT_STATUS[@]}" >> "$GITHUB_OUTPUT"
98- working-directory : ${{ github.repository }}
99-
100- # - name: Add files, commit and push
101- # if: steps.git_status.outputs.changes > 0
102- # run: |
103- # echo "Pushing changes to origin..."
104- # git add modules/archetypes/lib
105- # git commit -m '${{ env.pr_title }}'
106- # git push origin ${{ env.branch_name }}
107- # working-directory: ${{ github.repository }}
108-
109- # - name: Create pull request
110- # if: steps.git_status.outputs.changes > 0
111- # run: |
112- # HEAD_LABEL="${{ github.repository_owner }}:${{ env.branch_name }}"
113- # BASE_LABEL="${{ github.repository_owner }}:$(echo '${{ github.ref }}' | sed 's:refs/heads/::')"
114- # PULL_REQUEST_URL="repos/${{ github.repository }}/pulls"
115- # JQ_FILTER=".[] | select(.head.label == \"$HEAD_LABEL\") | select(.base.label == \"$BASE_LABEL\") | .url"
116- # CHECK_PULL_REQUEST_URL=$(gh api $PULL_REQUEST_URL | jq -r "$JQ_FILTER")
117- # if [ -z "$CHECK_PULL_REQUEST_URL" ]
118- # then
119- # CHECK_PULL_REQUEST_URL=$(gh pr create \
120- # --title "${{ env.pr_title }}" \
121- # --body "${{ env.pr_body }}" \
122- # --base "${{ github.ref }}" \
123- # --head "${{ env.branch_name }}" \
124- # --draft)
125- # echo "Created new PR: $CHECK_PULL_REQUEST_URL"
126- # else
127- # echo "Existing PR found: $CHECK_PULL_REQUEST_URL"
128- # fi
129- # working-directory: ${{ github.repository }}
130- # env:
131- # GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
132-
2+ name : Update Library Templates
3+
4+ # yamllint disable-line rule:truthy
5+ on :
6+ schedule :
7+ - cron : " 0 8 * * 1-5"
8+ workflow_dispatch :
9+ inputs :
10+ enterprise-scale-repository-branch :
11+ description : " The branch to target for the enterprise scale repository"
12+ required : false
13+ default : " main"
14+
15+ env :
16+ remote_repository : " Azure/Enterprise-Scale"
17+ remote_repository_branch : ${{ github.event.inputs.enterprise-scale-repository-branch != 'main' && github.event.inputs.enterprise-scale-repository-branch || 'main' }}
18+ branch_name : " patch-library-${{ github.run_number }}"
19+ pr_title : " Update Library Templates (automated)"
20+ pr_body :
21+ " This is an automated 'pull_request' containing updates to the library templates stored in 'modules/archetypes/lib'.\n
22+ Please review the 'files changed' tab to review changes."
23+
24+ jobs :
25+ update-templates :
26+ name : Update Library Templates
27+ runs-on : ubuntu-latest
28+ permissions :
29+ contents : write
30+ pull-requests : write
31+ steps :
32+ - name : Local repository checkout
33+ uses : actions/checkout@v4
34+ with :
35+ path : ${{ github.repository }}
36+ fetch-depth : 0
37+
38+ - name : Remote repository checkout
39+ uses : actions/checkout@v4
40+ with :
41+ repository : ${{ env.remote_repository }}
42+ path : ${{ env.remote_repository }}
43+ ref : ${{ env.remote_repository_branch }}
44+
45+ - uses : tibdex/github-app-token@v2
46+ id : generate-token
47+ with :
48+ app_id : ${{ secrets.APP_ID }}
49+ private_key : ${{ secrets.APP_PRIVATE_KEY }}
50+
51+ - name : Configure local git
52+ run : |
53+ git config user.name github-actions
54+ git config user.email [email protected] 55+ working-directory : ${{ github.repository }}
56+
57+ - name : Create and checkout branch
58+ run : |
59+ BRANCH_URL="repos/${{ github.repository }}/branches"
60+ JQ_FILTER=".[] | select(.name == \"${{ env.branch_name }}\").name"
61+ CHECK_BRANCH_ORIGIN=$(gh api $BRANCH_URL | jq -r "$JQ_FILTER")
62+ if [ -z "$CHECK_BRANCH_ORIGIN" ]
63+ then
64+ echo "Checkout local branch (create new, no origin)..."
65+ git checkout -b ${{ env.branch_name }}
66+ else
67+ echo "Checkout local branch (create new, track from origin)..."
68+ git checkout -b ${{ env.branch_name }} --track origin/${{ env.branch_name }}
69+ fi
70+ working-directory : ${{ github.repository }}
71+ env :
72+ GITHUB_TOKEN : ${{ steps.generate-token.outputs.token }}
73+
74+ - name : Update library templates
75+ uses : azure/powershell@v2
76+ with :
77+ inlineScript : |
78+ Write-Information "==> Running policy definitions script..." -InformationAction Continue
79+ ${{ github.repository }}/.github/scripts/Invoke-LibraryUpdatePolicyDefinitions.ps1 `
80+ -AlzToolsPath "${{ github.workspace }}/${{ env.remote_repository }}/src/Alz.Tools/" `
81+ -TargetPath "${{ github.workspace }}/${{ github.repository }}" `
82+ -SourcePath "${{ github.workspace }}/${{ env.remote_repository }}" `
83+ -Reset
84+
85+ Write-Information "==> Running policy assignments and archetypes script..." -InformationAction Continue
86+ ${{ github.repository }}/.github/scripts/Invoke-LibraryUpdatePolicyAssignmentArchetypes.ps1 `
87+ -AlzToolsPath "${{ github.workspace }}/${{ env.remote_repository }}/src/Alz.Tools/" `
88+ -TargetPath "${{ github.workspace }}/${{ github.repository }}" `
89+ -SourcePath "${{ github.workspace }}/${{ env.remote_repository }}"
90+ azPSVersion : " latest"
91+
92+ - name : Check for changes
93+ id : git_status
94+ run : |
95+ mapfile -t "CHECK_GIT_STATUS" < <(git status -s)
96+ printf "%s\n" "${CHECK_GIT_STATUS[@]}"
97+ echo "changes=${#CHECK_GIT_STATUS[@]}" >> "$GITHUB_OUTPUT"
98+ working-directory : ${{ github.repository }}
99+
100+ # - name: Add files, commit and push
101+ # if: steps.git_status.outputs.changes > 0
102+ # run: |
103+ # echo "Pushing changes to origin..."
104+ # git add modules/archetypes/lib
105+ # git commit -m '${{ env.pr_title }}'
106+ # git push origin ${{ env.branch_name }}
107+ # working-directory: ${{ github.repository }}
108+
109+ # - name: Create pull request
110+ # if: steps.git_status.outputs.changes > 0
111+ # run: |
112+ # HEAD_LABEL="${{ github.repository_owner }}:${{ env.branch_name }}"
113+ # BASE_LABEL="${{ github.repository_owner }}:$(echo '${{ github.ref }}' | sed 's:refs/heads/::')"
114+ # PULL_REQUEST_URL="repos/${{ github.repository }}/pulls"
115+ # JQ_FILTER=".[] | select(.head.label == \"$HEAD_LABEL\") | select(.base.label == \"$BASE_LABEL\") | .url"
116+ # CHECK_PULL_REQUEST_URL=$(gh api $PULL_REQUEST_URL | jq -r "$JQ_FILTER")
117+ # if [ -z "$CHECK_PULL_REQUEST_URL" ]
118+ # then
119+ # CHECK_PULL_REQUEST_URL=$(gh pr create \
120+ # --title "${{ env.pr_title }}" \
121+ # --body "${{ env.pr_body }}" \
122+ # --base "${{ github.ref }}" \
123+ # --head "${{ env.branch_name }}" \
124+ # --draft)
125+ # echo "Created new PR: $CHECK_PULL_REQUEST_URL"
126+ # else
127+ # echo "Existing PR found: $CHECK_PULL_REQUEST_URL"
128+ # fi
129+ # working-directory: ${{ github.repository }}
130+ # env:
131+ # GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
0 commit comments