Skip to content

Commit

Permalink
v2: App rewritten in Go (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam authored Sep 29, 2021
1 parent ce98410 commit 29f024e
Show file tree
Hide file tree
Showing 66 changed files with 3,912 additions and 705 deletions.
26 changes: 26 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Docs: <https://docs.codecov.io/docs/commit-status>

coverage:
# coverage lower than 50 is red, higher than 90 green
range: 30..80

status:
project:
default:
# Choose a minimum coverage ratio that the commit must meet to be considered a success.
#
# `auto` will use the coverage from the base commit (pull request base or parent commit) coverage to compare
# against.
target: auto

# Allow the coverage to drop by X%, and posting a success status.
threshold: 5%

# Resulting status will pass no matter what the coverage is or what other settings are specified.
informational: true

patch:
default:
target: auto
threshold: 5%
informational: true
13 changes: 10 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
.dockerignore
Dockerfile
.github
.git
.gitignore
/generator/node_modules
/generator/*.log
/out
.editorconfig
.idea
.vscode
test
temp
tmp
LICENSE
Makefile
error-pages
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# EditorConfig docs: <https://editorconfig.org/>

root = true

[*]
Expand All @@ -11,5 +13,5 @@ trim_trailing_whitespace = true
[*.{yml, yaml, sh, conf}]
indent_size = 2

[Makefile]
[{Makefile, go.mod, *.go}]
indent_style = tab
140 changes: 68 additions & 72 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,100 +5,96 @@ on:
types: [published]

jobs:
demo:
name: Update demonstration, hosted on github pages
build:
name: Build for ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
os: [linux, darwin] # linux, freebsd, darwin, windows
arch: [amd64] # amd64, 386
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup NodeJS
uses: actions/setup-node@v1 # Action page: <https://github.com/actions/setup-node>
with:
node-version: 15
- uses: actions/setup-go@v2
with: {go-version: 1.17.1}

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

- name: Install dependencies
working-directory: generator
run: yarn install

- name: Generate pages
run: ./generator/generator.js -i -c ./config.json -o ./out

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: content
path: out/
retention-days: 1
- uses: gacts/github-slug@v1
id: slug

- name: Switch to github pages branch
uses: actions/checkout@v2
with:
ref: gh-pages

- name: Download artifact
uses: actions/download-artifact@v2
- name: Generate builder values
id: values
run: echo "::set-output name=binary-name::error-pages-${{ matrix.os }}-${{ matrix.arch }}"

- name: Build application
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
LDFLAGS: -s -w -X github.com/tarampampam/error-pages/internal/version.version=${{ steps.slug.outputs.version }}
run: go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/error-pages/

- name: Upload binary file to release
uses: svenstaro/upload-release-action@v2
with:
name: content

- name: Setup git
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email 'actions@github.com'
git remote add github "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git"
- name: Stage changes
run: git add .

- name: Commit changes
run: git commit --allow-empty -m "Deploying ${GITHUB_SHA} to Github Pages"

- name: Push changes
run: git push github --force
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.values.outputs.binary-name }}
asset_name: ${{ steps.values.outputs.binary-name }}
tag: ${{ github.ref }}

docker-image:
name: Build docker image
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: actions/checkout@v2

- uses: gacts/github-slug@v1
id: slug

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

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

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

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

- name: Generate builder values
id: values
run: echo "::set-output name=version::${GITHUB_REF##*/[vV]}" # `/refs/tags/v1.2.3` -> `1.2.3`
- uses: docker/build-push-action@v2 # Action page: <https://github.com/docker/build-push-action>
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
build-args: "APP_VERSION=${{ steps.slug.outputs.version }}"
tags: |
tarampampam/error-pages:${{ steps.slug.outputs.version }}
tarampampam/error-pages:latest
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }}
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:latest
- name: Build image
demo:
name: Update the demonstration
runs-on: ubuntu-20.04
needs: [docker-image]
steps:
- uses: gacts/github-slug@v1
id: slug

- name: Take rendered templates from the built docker image
run: |
docker buildx build \
--platform "linux/amd64,linux/arm64/v8,linux/arm/v6,linux/arm/v7" \
--tag "tarampampam/error-pages:${{ steps.values.outputs.version }}" \
--tag "tarampampam/error-pages:latest" \
--tag "ghcr.io/${{ github.actor }}/error-pages:${{ steps.values.outputs.version }}" \
--tag "ghcr.io/${{ github.actor }}/error-pages:latest" \
--file ./Dockerfile \
--push \
.
docker create --name img ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }}
docker cp img:/opt/html ./out
docker rm -f img
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
Loading

0 comments on commit 29f024e

Please sign in to comment.