-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.67 KB
/
docker-image.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
name: Build and Publish Docker Image
on:
push:
branches: [ 'main' ]
jobs:
docker-build-and-push:
name: "Build and Publish Docker Image"
runs-on: ubuntu-latest
steps:
- name: Set Image Info
run: |
echo "::set-output name=tag::$(date +'%Y-%m-%d')-${{ github.run_number }}"
echo "::set-output name=created::$(date --rfc-3339=seconds | sed 's/ /T/')"
id: image_info
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
load: true
tags: keypr:${{ steps.image_info.outputs.tag }}
- name: Test
run: docker run --rm keypr:${{ steps.image_info.outputs.tag }}
- name: Build image and push to GitHub Container Registry
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
tags: |
ghcr.io/fr-platform/keypr:latest
ghcr.io/fr-platform/keypr:${{ steps.image_info.outputs.tag }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ steps.image_info.outputs.tag }}
org.opencontainers.image.created=${{ steps.image_info.outputs.created }}
push: ${{ github.ref == 'refs/heads/main' }}
cache-from: type=gha
cache-to: type=gha,mode=max