-
Notifications
You must be signed in to change notification settings - Fork 20
47 lines (47 loc) · 2.04 KB
/
bumpHugo.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
name: Bump Hugo
on:
workflow_dispatch:
schedule:
- cron: '30 2 * * 1'
env:
NPM_CACHE_NAME: 'npm-cache'
NPM_CACHE_PATH: '~/.npm'
jobs:
Bump:
name: Bump Hugo
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
token: ${{ secrets.WORKFLOW_GITHUB_TOKEN }}
- name: Bump thirdparties and create PR
env:
LOG_FILE: 'workflow.log'
PR_TITLE: 'build: bump Hugo'
BRANCH_NAME: 'build/bump_hugo'
GITHUB_TOKEN: ${{ secrets.WORKFLOW_GITHUB_TOKEN }}
run: |
minHugoVersion=$(grep -E '^min_version.*$' theme.toml)
minHugoVersion=${minHugoVersion#*\"}
minHugoVersion=${minHugoVersion%\"*}
latestHugoVersion=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.tag_name')
latestHugoVersion=${latestHugoVersion#*v}
printf "%70s\n" | tr ' ' '-'
printf "%-70s\n" "Minimum Hugo version: ${minHugoVersion}"
printf "%-70s\n" "Latest Hugo version : ${latestHugoVersion}"
printf "%70s\n" | tr ' ' '-'
sed -i 's/HUGO_TESTS_VERSIONS:.*/HUGO_TESTS_VERSIONS: '\'"${minHugoVersion}"' '"${latestHugoVersion}"\''/' .github/workflows/branches.yml
sed -i 's/HUGO_VERSION.*/HUGO_VERSION = "'"${latestHugoVersion}"'"/' netlify.toml
if [[ $(git status --porcelain | wc -l) -gt 0 ]];then
printf "%s\n" "chore:(bmyc): bump latest hugo version to ${latestHugoVersion}" > ${LOG_FILE}
git checkout -b ${BRANCH_NAME}
git add -u .
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
git commit -m "${PR_TITLE}"
git push -f origin ${BRANCH_NAME}
hub pull-request -f --file ${LOG_FILE} -l "internal" --base main --head ${BRANCH_NAME}
fi