error-pages/.github/workflows/release.yml

117 lines
4.4 KiB
YAML
Raw Normal View History

2020-07-08 11:12:21 +00:00
name: release
on:
release: # Docs: <https://git.io/JeBz1#release-event-release>
types: [published]
jobs:
2022-03-28 17:13:19 +00:00
purge-cdn-cache:
name: Purge jsDelivr CDN cache
runs-on: ubuntu-20.04
steps:
2022-03-30 16:23:42 +00:00
- uses: gacts/purge-jsdelivr-cache@v1 # Action page: <https://github.com/gacts/purge-jsdelivr-cache>
with:
url: |
https://cdn.jsdelivr.net/gh/tarampampam/error-pages@2/l10n/l10n.js
https://cdn.jsdelivr.net/gh/tarampampam/error-pages@2/l10n/l10n.min.js
https://cdn.jsdelivr.net/gh/tarampampam/error-pages@latest/l10n/l10n.js
https://cdn.jsdelivr.net/gh/tarampampam/error-pages@latest/l10n/l10n.min.js
2022-03-28 17:13:19 +00:00
2021-09-29 15:38:50 +00:00
build:
name: Build for ${{ matrix.os }} (${{ matrix.arch }})
2021-03-04 06:28:48 +00:00
runs-on: ubuntu-20.04
2021-09-29 15:38:50 +00:00
strategy:
fail-fast: false
matrix:
os: [linux, darwin] # linux, freebsd, darwin, windows
arch: [amd64] # amd64, 386
2020-07-08 11:12:21 +00:00
steps:
2022-04-01 08:01:22 +00:00
- uses: actions/setup-go@v3
with: {go-version: 1.19}
2020-07-08 11:12:21 +00:00
- uses: actions/checkout@v3
2020-07-08 11:12:21 +00:00
2021-09-29 15:38:50 +00:00
- uses: gacts/github-slug@v1
id: slug
2020-07-08 11:12:21 +00:00
2021-09-29 15:38:50 +00:00
- 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
2020-07-08 11:12:21 +00:00
with:
2021-09-29 15:38:50 +00:00
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.values.outputs.binary-name }}
asset_name: ${{ steps.values.outputs.binary-name }}
tag: ${{ github.ref }}
2020-07-08 11:12:21 +00:00
docker-image:
name: Build docker image
2021-03-04 06:28:48 +00:00
runs-on: ubuntu-20.04
2020-07-08 11:12:21 +00:00
steps:
- uses: actions/checkout@v3
2021-09-29 15:38:50 +00:00
- uses: gacts/github-slug@v1
id: slug
2021-04-13 13:55:03 +00:00
- uses: docker/setup-qemu-action@v2 # Action page: <https://github.com/docker/setup-qemu-action>
2021-04-13 13:55:03 +00:00
- uses: docker/setup-buildx-action@v2 # Action page: <https://github.com/docker/setup-buildx-action>
2021-04-13 13:55:03 +00:00
- uses: docker/login-action@v2 # Action page: <https://github.com/docker/login-action>
2021-07-20 10:05:06 +00:00
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
2021-04-13 13:55:03 +00:00
- uses: docker/login-action@v2 # Action page: <https://github.com/docker/login-action>
2021-07-20 10:05:06 +00:00
with:
registry: ghcr.io
username: ${{ github.actor }}
2022-05-12 12:20:02 +00:00
password: ${{ secrets.GITHUB_TOKEN }}
2020-07-08 11:12:21 +00:00
- uses: docker/build-push-action@v4 # Action page: <https://github.com/docker/build-push-action>
2021-09-29 15:38:50 +00:00
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 }}
2022-04-01 08:14:16 +00:00
tarampampam/error-pages:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
tarampampam/error-pages:${{ steps.slug.outputs.version-major }}
2021-09-29 15:38:50 +00:00
tarampampam/error-pages:latest
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }}
2022-04-01 08:14:16 +00:00
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version-major }}
2021-09-29 15:38:50 +00:00
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:latest
2020-07-08 11:12:21 +00:00
2021-09-29 15:38:50 +00:00
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
2021-04-13 13:55:03 +00:00
run: |
2021-09-29 15:38:50 +00:00
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