-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (130 loc) · 4.14 KB
/
build.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Build action-hugo
on:
workflow_dispatch:
push:
branches:
- build*
jobs:
version:
name: Get Build Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- id: version
run: |
echo "Github Ref: ${{ github.ref }}"
VERSION=${{ github.ref }}
echo "::set-output name=version::${VERSION#*-}"
hugo:
name: Checkout and build Hugo
runs-on: ubuntu-latest
needs: version
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Checkout hugo
uses: actions/checkout@v4.1.1
with:
path: hugodir
repository: gohugoio/hugo
submodules: true
fetch-depth: 0
- name: Build hugo
run: |
go version
(
cd hugodir
git fetch --all
git tag | sort -V > hugo_versions
git checkout ${{ needs.version.outputs.version }}
go install --tags extended
)
mv $HOME/go/bin/hugo .
mv hugodir/hugo_versions .
- uses: actions/upload-artifact@v4.3.1
with:
name: hugo
path: hugo
- uses: actions/upload-artifact@v4.3.1
with:
name: hugo_versions
path: hugo_versions
action:
name: Checkout action-hugo
runs-on: ubuntu-latest
needs: hugo
steps:
- name: Checkout action-hugo
uses: actions/checkout@v4.1.1
- name: Fetch all
run: git fetch --all
- name: Remove conflicting tags
run: |
for T in $(git tag); do
if [ "${T}" == "${{ needs.version.outputs.version }}" ]; then
git push origin :refs/tags/${{ needs.version.outputs.version }}
fi
done
- name: Remove conflicting branches
run: |
for B in $(git branch -r); do
if [ "${B}" == "origin/release-${{ needs.version.outputs.version }}" ]; then
git push origin :release-${{ needs.version.outputs.version }}
fi
done
build_and_push_container:
name: Build and push action-hugo container
runs-on: ubuntu-latest
needs:
- hugo
- version
- action
steps:
- uses: actions/checkout@v4.1.1
with:
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
- uses: actions/download-artifact@v5
with:
name: hugo
path: .
- uses: actions/download-artifact@v4.1.4
with:
name: hugo_versions
path: .
- run: chmod +x hugo
- name: Identify
run: |
git config --global user.email "github@utahcon.com"
git config --global user.name "Adam Barrett"
- name: Create and checkout release branch
run: git checkout -b release-${{ needs.version.outputs.version }}
- name: chmod hugo
run: chmod +x hugo
- name: Run hugo-scraper
run: ./hugo-scraper.sh
- name: chmod entrypoint
run: chmod +x entrypoint.sh
- name: commit action.yml entrypoint.sh and README.md
run: |
git add action.yml entrypoint.sh README.md
git commit -m "Documentation for ${{ needs.version.outputs.version }}"
- name: Create version tag
run: git tag -af ${{ needs.version.outputs.version }} -m "Version ${{ needs.version.outputs.version }}"
- name: Check latest tagging
run: |
HUGO_VERSION=$(curl https://api.github.com/repos/gohugoio/hugo/tags | jq -r .[0].name)
VERSION=${{ needs.version.outputs.version }}
if [ ${VERSION} == ${HUGO_VERSION} ]; then
git tag -af latest -m "Version ${{ needs.version.outputs.version }}"
fi
- uses: docker/build-push-action@v5.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
repository: utahcon/hugo
dockerfile: Containerfile
tags: ${{ needs.version.outputs.version }}
- name: Push release branch and tags
run: git push origin release-${{ needs.version.outputs.version }} --tags --force