-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (82 loc) · 2.87 KB
/
release-prod.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
name: Production Release
on:
push:
branches:
- main
jobs:
deploy-prod:
name: Check Release
runs-on: ubuntu-latest
steps:
- name: Checkout Actions
if: github.ref == 'refs/heads/main'
uses: actions/checkout@v4
with:
ref: ${{github.ref}}
persist-credentials: false
- name: Check Release
id: check_release
run: |
LAST_COMMIT_MESSAGE=`git log --pretty=format:%s -1`
PR_NUM=`echo "${LAST_COMMIT_MESSAGE}" | grep -o "#[[:digit:]].." | sed -e 's/#//' | head -1`
if [ ! -z "$PR_NUM" ] ; then \
TITLE=`echo "$LAST_COMMIT_MESSAGE" | grep -e "release" -e "Release"`
if [ ! -z "$TITLE" ] ; then \
echo "release=true" >> $GITHUB_OUTPUT
fi
fi
- name: Setup Hugo
if: steps.check_release.outputs.release == 'true'
uses: peaceiris/actions-hugo@v2
with:
hugo-version: latest
- name: Setup for Build
if: steps.check_release.outputs.release == 'true'
run: |
git config --global user.name "vdaas-ci"
git config --global user.email "ci@vdaas.org"
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git submodule update --init --recursive
cd public
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/vdaas/vald.git"
git checkout gh-pages
git pull origin gh-pages
env:
GITHUB_USER: ${{ secrets.DISPATCH_USER }}
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
- name: Production Build
if: steps.check_release.outputs.release == 'true'
run: |
make build/prod
- name: Check Changes public
id: git_diff_preview
run: |
diff=`git diff public/`
if [ ! -z "$diff" ] ; then \
echo "diff=true" >> $GITHUB_OUTPUT
fi
- name: Production Deploy
if: steps.git_diff_preview.outputs.diff
run: |
export LATEST_VERSION=$(make version/latest)
cd public
git checkout gh-pages
git add .
git commit --signoff -m ":arrow_up: v${LATEST_VERSION} `date`"
git push origin gh-pages
env:
GITHUB_USER: ${{ secrets.DISPATCH_USER }}
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
- name: Commit Production Changes
if: steps.git_diff_preview.outputs.diff
run: |
git checkout main
git diff
git branch
git log --oneline -n1
git add public
git commit --signoff -m ":robot: auto update production :arrow_up:"
git push origin ${{ github.head_ref }}
env:
GITHUB_USER: ${{ secrets.DISPATCH_USER }}
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}