22
22
build :
23
23
name : Build and push docker image
24
24
runs-on : ubuntu-latest
25
- strategy :
26
- matrix :
27
- platform : [linux/amd64, linux/arm64]
28
-
29
25
steps :
30
26
- name : Checkout
31
27
uses : actions/checkout@v4
46
42
47
43
- name : Docker metadata
48
44
# disable this step
49
- # if: false
45
+ if : false
50
46
id : metadata
51
47
uses : docker/metadata-action@v5
52
48
with :
@@ -58,43 +54,30 @@ jobs:
58
54
59
55
- name : Log in to Docker Hub
60
56
uses : docker/login-action@v3
61
- # if: ${{ github.ref_type == 'tag' }}
62
57
with :
63
58
username : ${{ secrets.DOCKER_USERNAME }}
64
59
password : ${{ secrets.DOCKER_PASSWORD }}
65
60
66
- - name : Set environment variables for each architecture
67
- run : |
68
- if [[ "${{ matrix.platform }}" == "linux/amd64" ]]; then
69
- echo "SITE_URL=${{ env.SITE_URL_AMD64 }}" >> $GITHUB_ENV
70
- elif [[ "${{ matrix.platform }}" == "linux/arm64" ]]; then
71
- echo "SITE_URL=${{ env.SITE_URL_ARM64 }}" >> $GITHUB_ENV
72
- fi
73
-
74
- # Must be in separate step to reflect
75
- - name : Debug assigned environment variable
76
- run : |
77
- echo "Debug: PLATFORM: ${{ matrix.platform }}, SITE_URL: ${{ env.SITE_URL }}"
78
-
79
61
- name : Build and push Docker image
80
62
uses : docker/build-push-action@v6
81
63
with :
82
64
# src dir
83
65
context : ./
84
66
# Dockerfile dir
85
67
file : ./docker/Dockerfile
86
- # platforms: linux/amd64,linux/arm64
87
- platforms : ${{ matrix.platform }}
68
+ # cant use matrix, must pass platforms like this
69
+ platforms : linux/amd64,linux/arm64
88
70
build-args : |
89
- "ARG_SITE_URL=${{ env.SITE_URL }}"
71
+ "ARG_SITE_URL_ARM64=${{ env.SITE_URL_ARM64 }}"
72
+ "ARG_SITE_URL_AMD64=${{ env.SITE_URL_AMD64 }}"
90
73
"ARG_PLAUSIBLE_SCRIPT_URL=${{ env.PLAUSIBLE_SCRIPT_URL }}"
91
74
"ARG_PLAUSIBLE_DOMAIN=${{ env.PLAUSIBLE_DOMAIN }}"
92
75
push : true
93
76
tags : ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest
94
- cache-to : type=inline
77
+ # cache-to: type=inline
78
+ cache-from : type=registry,ref=${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache
79
+ cache-to : type=registry,ref=${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
95
80
96
81
# disabled metadata step
97
82
# tags: ${{ steps.metadata.outputs.tags }}
98
83
# labels: ${{ steps.metadata.outputs.labels }}
99
- # cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache
100
- # cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
0 commit comments