Spaces:
Running
Running
neon_arch
leon3s
commited on
Commit
Β·
95c6bee
1
Parent(s):
9bb1544
π· ci: automate the docker image build & uploading process (#323)
Browse filesCo-authored-by: leon3s <[email protected]>
- .github/workflows/docker.yml +79 -0
.github/workflows/docker.yml
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Release stable image
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- "release/stable/**"
|
7 |
+
pull_request:
|
8 |
+
branches:
|
9 |
+
- "release/stable/**"
|
10 |
+
types: [opened, synchronize]
|
11 |
+
|
12 |
+
env:
|
13 |
+
CARGO_TERM_COLOR: always
|
14 |
+
|
15 |
+
jobs:
|
16 |
+
release_image:
|
17 |
+
strategy:
|
18 |
+
fail-fast: false
|
19 |
+
matrix:
|
20 |
+
cache:
|
21 |
+
- memory
|
22 |
+
- redis
|
23 |
+
- hybrid
|
24 |
+
- no-cache
|
25 |
+
|
26 |
+
name: Release ${{ matrix.cache }} image
|
27 |
+
runs-on: ubuntu-latest
|
28 |
+
|
29 |
+
steps:
|
30 |
+
- uses: actions/checkout@v3
|
31 |
+
# Install buildx
|
32 |
+
- name: Set up Docker Buildx
|
33 |
+
id: buildx
|
34 |
+
uses: docker/setup-buildx-action@v2
|
35 |
+
# Set buildx cache
|
36 |
+
- name: Cache register
|
37 |
+
uses: actions/cache@v3
|
38 |
+
with:
|
39 |
+
path: /tmp/.buildx-cache
|
40 |
+
key: buildx-cache
|
41 |
+
# Login to ghcr.io
|
42 |
+
- name: Log in to Docker Hub
|
43 |
+
uses: docker/login-action@v2
|
44 |
+
with:
|
45 |
+
username: neonmmd
|
46 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
47 |
+
# Extract branch info
|
48 |
+
- name: Set info
|
49 |
+
run: |
|
50 |
+
echo "VERSION=$(echo ${GITHUB_REF} | awk -F/ '{print $6}')" >> $GITHUB_ENV
|
51 |
+
# Print info for debug
|
52 |
+
- name: Print Info
|
53 |
+
run: |
|
54 |
+
echo $VERSION
|
55 |
+
# Create buildx multiarch
|
56 |
+
- name: Create buildx multiarch
|
57 |
+
run: docker buildx create --use --name=buildx-multi-arch --driver=docker-container --driver-opt=network=host
|
58 |
+
# Modify cache variable in the dockerfile.
|
59 |
+
- name: Modify Cache variable
|
60 |
+
run: |
|
61 |
+
sed -i "s/ARG CACHE=[a-z]*/ARG CACHE=${{ matrix.cache }}/g" Dockerfile
|
62 |
+
# Publish image
|
63 |
+
- name: Publish image
|
64 |
+
run: docker buildx build --builder=buildx-multi-arch --platform=linux/amd64,linux/arm64 --build-arg CACHE=${{ matrix.cache }} --push -t neonmmd/websurfx:$VERSION-${{ matrix.cache }} -t neon-mmd/websurfx:${{matrix.cache}} -f Dockerfile .
|
65 |
+
- name: Publish latest
|
66 |
+
if: ${{ matrix.cache }} == 'hybrid'
|
67 |
+
run: docker buildx build --builder=buildx-multi-arch --platform=linux/amd64,linux/arm64 --build-arg CACHE=${{ matrix.cache }} --push -t neon-mmd/websurfx:latest -f Dockerfile .
|
68 |
+
# Upload it to release
|
69 |
+
- name: Test if release already exists
|
70 |
+
id: release-exists
|
71 |
+
continue-on-error: true
|
72 |
+
run: gh release view $BINARY_NAME-$VERSION
|
73 |
+
env:
|
74 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
75 |
+
- name: Create new draft release
|
76 |
+
if: steps.release-exists.outcome == 'failure' && steps.release-exists.conclusion == 'success'
|
77 |
+
run: gh release create -t $VERSION -d $VERSION
|
78 |
+
env:
|
79 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|