-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (45 loc) · 1.52 KB
/
Copy pathupdateHash.yml
File metadata and controls
54 lines (45 loc) · 1.52 KB
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
name: Update Commit Hash
on:
push:
branches:
- main # Change if needed
permissions:
contents: write
jobs:
update-hash:
runs-on: ubuntu-latest
steps:
# 1. Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: true
# 2. Skip if last commit was made by GitHub Actions (to avoid loops)
- name: Check last commit author
id: check
run: |
LAST_AUTHOR=$(git log -1 --pretty=format:'%an')
echo "last_author=$LAST_AUTHOR" >> $GITHUB_OUTPUT
- name: Skip if commit was by GitHub Actions
if: ${{ steps.check.outputs.last_author == 'github-actions' }}
run: |
echo "Last commit was by github-actions, skipping workflow."
exit 0
# 3. Update public/commit.txt
- name: Update commit.txt
run: |
mkdir -p public
echo "$GITHUB_SHA" > public/commit.txt
# 4. Configure Git
- name: Configure Git
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
# 5. Commit changes if any
- name: Commit updated commit.txt
run: |
git add public/commit.txt
git commit -m "Add Current Version Hash (Not an Update)" -m "This commit updates public/commit.txt to facilitate correct versioning and tracking of the deployed version." || echo "No changes to commit"
# 6. Push back
- name: Push changes
run: git push