forked from aruppi/aruppi-api
-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (95 loc) · 3.15 KB
/
docker-deploy.yaml
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# This wrorkflow checkouts the latest src code, builds a docker image and
# push it to DockerHun and GitHub Container Registry
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Publish Docker image
on:
push:
#branches: [ v5 ]
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
#paths:
# - 'src/*'
# - '!src/main/resources/*'
workflow_dispatch:
jobs:
build-and-push:
name: Build Docker image and push to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
# Step 1: Source code checkout
- name: Source code checkout
uses: actions/checkout@v4
#- name: Gradle cache
# uses: actions/setup-java@v4
# with:
# distribution: 'corretto'
# java-version: '21'
# cache: 'gradle'
#
#- name: Setup Gradle
# uses: gradle/actions/setup-gradle@v4
#
#- name: Gradle build
# run: ./gradlew build --no-daemon
# Step 2: Configure Docker Buildx
- name: Configure Docker Buildx
uses: docker/setup-buildx-action@v3
# Step 2.5: Setup QEMU
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Step 3: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Step 4: GitHub Container Registry login
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
# Step 5: Configure image tags
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/aruppi-api
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
# Step 6: Build and publish to Docker Hub and GitHub Container Registry
- name: Build and publish
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
#platforms: linux/amd64,linux/arm64
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
#github-token: ${{ secrets.GHCR_TOKEN }}
## Step 7: Generate artifact attestation
#- name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true