Skip to content

2.4.0

2.4.0 #67

Workflow file for this run

#
# Better Go Playground Docker image deployment workflow
#
# Builds and deploys image to Docker hub when a new release created.
# Uses DOCKERHUB_USERNAME and DOCKERHUB_TOKEN env vars from GitHub repo secrets.
#
# see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
#
name: Build Docker Image
on:
release:
types:
- created
env:
GO_VERSION: 1.23
NODE_VERSION: lts/iron
WASM_API_VER: v2
PREV_GO_VERSION: 1.22
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
env:
cache-name: npm-cache
with:
path: "web/node_modules"
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Set release version
run: |
echo "Release version ${GITHUB_REF#refs/*/v}"
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
x1unix/go-playground
ghcr.io/${{ github.repository }}/go-playground
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- uses: actions/setup-node@v4
with:
node-version: "${{env.NODE_VERSION}}"
- name: Setup dependencies
run: sudo apt-get update && sudo apt-get install -y make
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: |
go.sum
- name: Build generated frontend files
run: make ci-assets
- name: Build frontend
run: |
yarn install --silent && yarn build
working-directory: ./web
env:
NODE_ENV: "production"
VITE_VERSION: "${{ env.RELEASE_VERSION }}"
VITE_GITHUB_URL: "${{ github.server_url }}/${{ github.repository }}"
VITE_GO_VERSION: "${{ env.GO_VERSION }}"
VITE_PREV_GO_VERSION: "${{ env.PREV_GO_VERSION }}"
VITE_WASM_API_VER: "${{ env.WASM_API_VER }}"
VITE_WASM_BASE_URL: "/wasm"
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./build/release.dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
WASM_API_VER=${{ env.WASM_API_VER }}
APP_VERSION=${{ env.RELEASE_VERSION }}
push: true
- name: Print image digest
run: echo ${{ steps.docker_build.outputs.digest }}