This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (78 loc) · 2.95 KB
/
docker-image.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
80
81
82
83
84
85
86
87
88
89
90
# TODO: test on arm (raspberry pi)
# TODO: split built to mutualise front when multiple platforms
name: docker-image
on:
push:
branches:
- "main"
release:
types: [published]
jobs:
build:
name: Build container
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.HUB_TOKEN }}
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute app environment and docker tags
id: compute-vars
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "::set-output name=app-version::${{ github.event.release.tag_name }}"
echo "::set-output name=docker-tag1::latest"
echo "::set-output name=docker-tag2::${{ github.event.release.tag_name }}"
else
echo "::set-output name=app-version::${{ github.sha }}"
echo "::set-output name=docker-tag1::develop"
echo "::set-output name=docker-tag2::${{ github.sha }}"
fi
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
#platforms: linux/amd64,linux/arm/v6,linux/arm/v7
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.compute-vars.outputs.docker-tag1 }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.compute-vars.outputs.docker-tag2 }}
${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.compute-vars.outputs.docker-tag1 }}
${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.compute-vars.outputs.docker-tag2 }}
build-args: |
APP_VERSION=${{ steps.compute-vars.outputs.app-version }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
sync-description:
name: Docker Hub - Sync description
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare README
run: |
cat README.md | sed -e 's/ghcr.io\///g' > README_hub.md
- name: Sync README and description
uses: bemble/[email protected]
with:
pass: ${{ secrets.HUB_TOKEN }}
totp_secret: ${{ secrets.HUB_TOTP_SECRET }}
description: true
readme: ./README_hub.md