-
Notifications
You must be signed in to change notification settings - Fork 4
87 lines (72 loc) · 2.44 KB
/
version_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
name: File Versioning
on:
push:
branches:
- '*'
tags:
- '*'
jobs:
update_versioning:
runs-on: ubuntu-latest
env:
API_KEY: ${{ secrets.API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
steps:
- name: Check out the repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch the complete commit history
- name: Set up Git
run: |
git config user.email "actions@wcrp-cmip.org"
git config user.name "CMIP-IPO: Automated GitHub Action"
git config credential.helper store
git config --global user.email "actions@wcrp-cmip.org"
git config --global user.name "CMIP-IPO GitHub Action"
git config --global push.default current
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
shell: bash
- name: Update Versioning
id: run-python-script
run: python .github/libs/version.py -t ${GH_TOKEN}
# working-directory: .github/libs # Adjusted the working directory
shell: bash
# - name: Display Version Metadata for JSON Files
# run: |
# # Get the list of JSON files in the repository
# json_files=$(git ls-tree --name-only -r HEAD | grep '\.json$')
# # Iterate over each JSON file and display 'version_metadata'
# for json_file in $json_files; do
# metadata=$(git show HEAD:$json_file | jq '.version_metadata')
# if [ $? -eq 0 ] && [ "$metadata" != "null" ]; then
# echo "File: $json_file, Version Metadata: $metadata"
# fi
# done
# shell: bash
# continue-on-error: true
- name: Write Changes
run: |
if [ -z "$ACT" ]; then
timestamp=$(date -u +"%Y-%m-%d %H:%M UTC")
git add -A
git commit -m 'Automated Versioning Update'
git push origin $(git rev-parse --abbrev-ref HEAD)
else
echo "Skipping this step in 'act' environment."
fi
shell: bash
continue-on-error: true