-
-
Notifications
You must be signed in to change notification settings - Fork 98
121 lines (104 loc) · 3.51 KB
/
Copy pathrelease.yml
File metadata and controls
121 lines (104 loc) · 3.51 KB
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
#
# 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.26
WASM_API_VER: v3
PREV_GO_VERSION: 1.25
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/cache@v5
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@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version metadata
id: meta
uses: docker/metadata-action@v6
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@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v6
with:
cache: "yarn"
node-version-file: ".nvmrc"
cache-dependency-path: "web/yarn.lock"
- name: Setup dependencies
run: sudo apt-get update && sudo apt-get install -y make
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v6
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@v7
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 }}