-
-
Notifications
You must be signed in to change notification settings - Fork 7
75 lines (65 loc) · 2.37 KB
/
docker-push.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
name: Push Multi-Arch Docker Image to Docker Hub
on:
push:
branches: [ "main" ] #, "dev" ]
paths:
# - ".github/workflows/docker-push.yml"
- "Dockerfile"
- "docker-compose.yml"
- "go.mod"
- "go.sum"
- "probe.js"
- "src/*"
- "*.go"
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@7ca345011ac4304463197fac0e56eab1bc7e6af0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@b53be03109c4ef6f6cc7aa545b84b17a7fe51c1e
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} # Remove raw dev tag to add the dev branch back to being seperate
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }}
- name: Create .env file
run: touch .env
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}"
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./Dockerfile
target: prod
build-args: |
GIT_TAG=${{ github.ref_name }}
GIT_COMMIT=${{ github.sha }}
GIT_BRANCH=${{ github.ref_name }}
# - name: Create and push manifest
# run: |
# docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
# --amend ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
# --amend ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
# docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest