Skip to content

Commit 29f024e

Browse files
authored
v2: App rewritten in Go (#25)
1 parent ce98410 commit 29f024e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3912
-705
lines changed

.codecov.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Docs: <https://docs.codecov.io/docs/commit-status>
2+
3+
coverage:
4+
# coverage lower than 50 is red, higher than 90 green
5+
range: 30..80
6+
7+
status:
8+
project:
9+
default:
10+
# Choose a minimum coverage ratio that the commit must meet to be considered a success.
11+
#
12+
# `auto` will use the coverage from the base commit (pull request base or parent commit) coverage to compare
13+
# against.
14+
target: auto
15+
16+
# Allow the coverage to drop by X%, and posting a success status.
17+
threshold: 5%
18+
19+
# Resulting status will pass no matter what the coverage is or what other settings are specified.
20+
informational: true
21+
22+
patch:
23+
default:
24+
target: auto
25+
threshold: 5%
26+
informational: true

.dockerignore

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
.dockerignore
2+
Dockerfile
23
.github
34
.git
45
.gitignore
5-
/generator/node_modules
6-
/generator/*.log
7-
/out
6+
.editorconfig
7+
.idea
8+
.vscode
9+
test
10+
temp
11+
tmp
12+
LICENSE
13+
Makefile
14+
error-pages

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# EditorConfig docs: <https://editorconfig.org/>
2+
13
root = true
24

35
[*]
@@ -11,5 +13,5 @@ trim_trailing_whitespace = true
1113
[*.{yml, yaml, sh, conf}]
1214
indent_size = 2
1315

14-
[Makefile]
16+
[{Makefile, go.mod, *.go}]
1517
indent_style = tab

.github/workflows/release.yml

Lines changed: 68 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,100 +5,96 @@ on:
55
types: [published]
66

77
jobs:
8-
demo:
9-
name: Update demonstration, hosted on github pages
8+
build:
9+
name: Build for ${{ matrix.os }} (${{ matrix.arch }})
1010
runs-on: ubuntu-20.04
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [linux, darwin] # linux, freebsd, darwin, windows
15+
arch: [amd64] # amd64, 386
1116
steps:
12-
- name: Check out code
13-
uses: actions/checkout@v2
14-
15-
- name: Setup NodeJS
16-
uses: actions/setup-node@v1 # Action page: <https://github.com/actions/setup-node>
17-
with:
18-
node-version: 15
17+
- uses: actions/setup-go@v2
18+
with: {go-version: 1.17.1}
1919

20-
- uses: actions/cache@v2
21-
with:
22-
path: '**/node_modules'
23-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
20+
- uses: actions/checkout@v2
2421

25-
- name: Install dependencies
26-
working-directory: generator
27-
run: yarn install
28-
29-
- name: Generate pages
30-
run: ./generator/generator.js -i -c ./config.json -o ./out
31-
32-
- name: Upload artifact
33-
uses: actions/upload-artifact@v2
34-
with:
35-
name: content
36-
path: out/
37-
retention-days: 1
22+
- uses: gacts/github-slug@v1
23+
id: slug
3824

39-
- name: Switch to github pages branch
40-
uses: actions/checkout@v2
41-
with:
42-
ref: gh-pages
43-
44-
- name: Download artifact
45-
uses: actions/download-artifact@v2
25+
- name: Generate builder values
26+
id: values
27+
run: echo "::set-output name=binary-name::error-pages-${{ matrix.os }}-${{ matrix.arch }}"
28+
29+
- name: Build application
30+
env:
31+
GOOS: ${{ matrix.os }}
32+
GOARCH: ${{ matrix.arch }}
33+
CGO_ENABLED: 0
34+
LDFLAGS: -s -w -X github.com/tarampampam/error-pages/internal/version.version=${{ steps.slug.outputs.version }}
35+
run: go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/error-pages/
36+
37+
- name: Upload binary file to release
38+
uses: svenstaro/upload-release-action@v2
4639
with:
47-
name: content
48-
49-
- name: Setup git
50-
run: |
51-
git config --global user.name "$GITHUB_ACTOR"
52-
git config --global user.email '[email protected]'
53-
git remote add github "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git"
54-
55-
- name: Stage changes
56-
run: git add .
57-
58-
- name: Commit changes
59-
run: git commit --allow-empty -m "Deploying ${GITHUB_SHA} to Github Pages"
60-
61-
- name: Push changes
62-
run: git push github --force
40+
repo_token: ${{ secrets.GITHUB_TOKEN }}
41+
file: ${{ steps.values.outputs.binary-name }}
42+
asset_name: ${{ steps.values.outputs.binary-name }}
43+
tag: ${{ github.ref }}
6344

6445
docker-image:
6546
name: Build docker image
6647
runs-on: ubuntu-20.04
6748
steps:
68-
- name: Check out code
69-
uses: actions/checkout@v2
49+
- uses: actions/checkout@v2
50+
51+
- uses: gacts/github-slug@v1
52+
id: slug
7053

71-
- name: Set up QEMU
72-
uses: docker/setup-qemu-action@v1 # Action page: <https://github.com/docker/setup-qemu-action>
54+
- uses: docker/setup-qemu-action@v1 # Action page: <https://github.com/docker/setup-qemu-action>
7355

74-
- name: Set up Docker Buildx
75-
uses: docker/setup-buildx-action@v1 # Action page: <https://github.com/docker/setup-buildx-action>
56+
- uses: docker/setup-buildx-action@v1 # Action page: <https://github.com/docker/setup-buildx-action>
7657

77-
- name: Login to default Container Registry
78-
uses: docker/login-action@v1 # Action page: <https://github.com/docker/login-action>
58+
- uses: docker/login-action@v1 # Action page: <https://github.com/docker/login-action>
7959
with:
8060
username: ${{ secrets.DOCKER_LOGIN }}
8161
password: ${{ secrets.DOCKER_PASSWORD }}
8262

83-
- name: Login to GitHub Container Registry
84-
uses: docker/login-action@v1 # Action page: <https://github.com/docker/login-action>
63+
- uses: docker/login-action@v1 # Action page: <https://github.com/docker/login-action>
8564
with:
8665
registry: ghcr.io
8766
username: ${{ github.actor }}
8867
password: ${{ secrets.GHCR_PASSWORD }}
8968

90-
- name: Generate builder values
91-
id: values
92-
run: echo "::set-output name=version::${GITHUB_REF##*/[vV]}" # `/refs/tags/v1.2.3` -> `1.2.3`
69+
- uses: docker/build-push-action@v2 # Action page: <https://github.com/docker/build-push-action>
70+
with:
71+
context: .
72+
file: Dockerfile
73+
push: true
74+
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
75+
build-args: "APP_VERSION=${{ steps.slug.outputs.version }}"
76+
tags: |
77+
tarampampam/error-pages:${{ steps.slug.outputs.version }}
78+
tarampampam/error-pages:latest
79+
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }}
80+
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:latest
9381
94-
- name: Build image
82+
demo:
83+
name: Update the demonstration
84+
runs-on: ubuntu-20.04
85+
needs: [docker-image]
86+
steps:
87+
- uses: gacts/github-slug@v1
88+
id: slug
89+
90+
- name: Take rendered templates from the built docker image
9591
run: |
96-
docker buildx build \
97-
--platform "linux/amd64,linux/arm64/v8,linux/arm/v6,linux/arm/v7" \
98-
--tag "tarampampam/error-pages:${{ steps.values.outputs.version }}" \
99-
--tag "tarampampam/error-pages:latest" \
100-
--tag "ghcr.io/${{ github.actor }}/error-pages:${{ steps.values.outputs.version }}" \
101-
--tag "ghcr.io/${{ github.actor }}/error-pages:latest" \
102-
--file ./Dockerfile \
103-
--push \
104-
.
92+
docker create --name img ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }}
93+
docker cp img:/opt/html ./out
94+
docker rm -f img
95+
96+
- name: Deploy to GitHub Pages
97+
uses: peaceiris/actions-gh-pages@v3
98+
with:
99+
github_token: ${{ secrets.GITHUB_TOKEN }}
100+
publish_dir: ./out

0 commit comments

Comments
 (0)