Skip to content

Commit c858799

Browse files
committed
Update CI/CD
1 parent cc22e5a commit c858799

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

.github/workflows/docker.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,72 @@
11
name: Build and push
22

3+
permissions:
4+
contents: read
5+
6+
env:
7+
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/ssh-key-authority
8+
39
on:
410
push:
511
branches: [ "master", "dev" ]
612
pull_request:
713
branches: [ "master", "dev" ]
14+
release:
15+
types: [ published ]
816

917
jobs:
1018
build:
19+
if: github.event_name != 'release'
1120
runs-on: ubuntu-latest
1221
steps:
13-
- name: Login to Docker Hub
22+
- &checkout-step
23+
name: Check out repository
24+
uses: actions/checkout@v4
25+
26+
- &setup-qemu-step
27+
name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
30+
- &login-step
31+
name: Login to Docker Hub
1432
uses: docker/login-action@v3
1533
with:
1634
username: ${{ secrets.DOCKERHUB_USERNAME }}
1735
password: ${{ secrets.DOCKERHUB_TOKEN }}
1836

19-
- name: Set up Docker Buildx
37+
- &setup-buildx-step
38+
name: Set up Docker Buildx
2039
uses: docker/setup-buildx-action@v3
2140

2241
- name: Build and push
2342
uses: docker/build-push-action@v6
2443
with:
44+
context: .
45+
push: true
46+
platforms: linux/amd64,linux/arm64,linux/arm/v7
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max
49+
tags: |
50+
${{ env.IMAGE_NAME }}:latest-${{ github.ref_name }}
51+
52+
release:
53+
if: github.event_name == 'release'
54+
runs-on: ubuntu-latest
55+
steps:
56+
- *checkout-step
57+
58+
- *setup-qemu-step
59+
60+
- *login-step
61+
62+
- *setup-buildx-step
63+
64+
- name: Build and push release image
65+
uses: docker/build-push-action@v6
66+
with:
67+
context: .
2568
push: true
26-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ssh-key-authority:latest-${{ vars.GITHUB_REF_NAME }}
69+
platforms: linux/amd64,linux/arm64,linux/arm/v7
70+
tags: |
71+
${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
72+
${{ env.IMAGE_NAME }}:latest

0 commit comments

Comments
 (0)