Skip to content

Commit 839e85c

Browse files
chore: update workflows to use dynamic EXERCISE_TOOLKIT_REF environment variable, add a workflow to update it (#51)
1 parent a7add33 commit 839e85c

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Update Self-References
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
# Currently reusable workflows only use markdown-templates but this may be extended to actions and other files in the future
9+
- "markdown-templates/**"
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
update_versions:
18+
name: Update Exercise Toolkit Version References
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Update EXERCISE_TOOLKIT_REF in workflow files
28+
uses: jacobtomlinson/gha-find-replace@v3
29+
with:
30+
find: 'EXERCISE_TOOLKIT_REF: [^\s]+'
31+
replace: "EXERCISE_TOOLKIT_REF: ${{ github.sha }}"
32+
include: ".github/workflows/*.yml"
33+
exclude: ".github/workflows/_*.yml"
34+
regex: true
35+
36+
- name: Create Pull Request
37+
uses: peter-evans/create-pull-request@v7
38+
with:
39+
commit-message: "chore: update exercise-toolkit self-references to latest commit"
40+
title: "chore: update exercise-toolkit self-references to latest commit"
41+
body: |
42+
## 🔄 Automated Version Update
43+
44+
This PR automatically updates the `EXERCISE_TOOLKIT_REF` environment variable in reusable workflows to reference the latest commit
45+
46+
---
47+
*This PR was automatically created by the `update-self-references` workflow.*
48+
branch: update-self-refs
49+
delete-branch: true
50+
add-paths: |
51+
.github/workflows/*.yml
52+
draft: false
53+
reviewers: |
54+
FidelusAleksander
55+
labels: |
56+
skip-release-notes
57+
maintenance

.github/workflows/finish-exercise.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ permissions:
1717
contents: write
1818
issues: write
1919

20+
env:
21+
EXERCISE_TOOLKIT_REF: v0.5.0
22+
2023
jobs:
2124
update_readme:
2225
name: Update README with congratulations
@@ -34,7 +37,7 @@ jobs:
3437
with:
3538
repository: skills/exercise-toolkit
3639
path: exercise-toolkit
37-
ref: v0.5.0
40+
ref: ${{ env.EXERCISE_TOOLKIT_REF }}
3841

3942
- name: Build congratulations message from template
4043
id: build-new-readme
@@ -67,7 +70,7 @@ jobs:
6770
with:
6871
repository: skills/exercise-toolkit
6972
path: exercise-toolkit
70-
ref: v0.5.0
73+
ref: ${{ env.EXERCISE_TOOLKIT_REF }}
7174

7275
- name: Build message - exercise finished
7376
id: build-finish-message

.github/workflows/start-exercise.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ permissions:
2929
actions: write # Disable workflows
3030
issues: write # Create issue
3131

32+
env:
33+
EXERCISE_TOOLKIT_REF: v0.5.0
34+
3235
jobs:
3336
disable_workflows:
3437
name: Disable exercise workflows
@@ -64,7 +67,7 @@ jobs:
6467
with:
6568
repository: skills/exercise-toolkit
6669
path: exercise-toolkit
67-
ref: v0.5.0
70+
ref: ${{ env.EXERCISE_TOOLKIT_REF }}
6871

6972
- name: Build welcome message from template
7073
id: build-issue-description
@@ -107,7 +110,7 @@ jobs:
107110
with:
108111
repository: skills/exercise-toolkit
109112
path: exercise-toolkit
110-
ref: v0.5.0
113+
ref: ${{ env.EXERCISE_TOOLKIT_REF }}
111114

112115
- name: Build welcome message from template
113116
id: build-new-readme

0 commit comments

Comments
 (0)