-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (48 loc) · 1.61 KB
/
Copy pathdocker-publish.yml
File metadata and controls
57 lines (48 loc) · 1.61 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
name: Build and Push Multi-Arch Docker image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get version
id: version
run: |
VERSION=$(cat version.txt)
echo "Version from file: ${VERSION}"
echo "VERSION=${VERSION}" >> ${GITHUB_OUTPUT}
- name: Fail if tag already exists
run: |
TAG="v${{ steps.version.outputs.version }}"
if git ls-remote --tags origin "refs/tags/$TAG" | grep "$TAG" > /dev/null; then
echo "❌ Tag $TAG already exists. Aborting."
exit 1
fi
- name: Build and push Docker image (multi-arch)
uses: docker/build-push-action@v5
with:
context: docker
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ secrets.DOCKER_USERNAME }}/speedtest-monitor:latest
${{ secrets.DOCKER_USERNAME }}/speedtest-monitor:${{ steps.version.outputs.VERSION }}
- name: Create tag if it doesn't exist
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag "v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"