-
Notifications
You must be signed in to change notification settings - Fork 97
79 lines (74 loc) · 2.59 KB
/
docker.yml
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
name: Release stable image
on:
push:
branches:
- "release/stable/**"
pull_request:
branches:
- "release/stable/**"
types: [opened, synchronize]
env:
CARGO_TERM_COLOR: always
jobs:
release_image:
strategy:
fail-fast: false
matrix:
cache:
- memory
- redis
- hybrid
- no-cache
name: Release ${{ matrix.cache }} image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# Set buildx cache
- name: Cache register
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: buildx-cache
# Login to ghcr.io
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: neonmmd
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract branch info
- name: Set info
run: |
echo "VERSION=$(echo ${GITHUB_REF} | awk -F/ '{print $6}')" >> $GITHUB_ENV
# Print info for debug
- name: Print Info
run: |
echo $VERSION
# Create buildx multiarch
- name: Create buildx multiarch
run: docker buildx create --use --name=buildx-multi-arch --driver=docker-container --driver-opt=network=host
# Modify cache variable in the dockerfile.
- name: Modify Cache variable
run: |
sed -i "s/ARG CACHE=[a-z]*/ARG CACHE=${{ matrix.cache }}/g" Dockerfile
# Publish image
- name: Publish image
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 .
- name: Publish latest
if: ${{ matrix.cache }} == 'hybrid'
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 .
# Upload it to release
- name: Test if release already exists
id: release-exists
continue-on-error: true
run: gh release view $BINARY_NAME-$VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new draft release
if: steps.release-exists.outcome == 'failure' && steps.release-exists.conclusion == 'success'
run: gh release create -t $VERSION -d $VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}