-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (40 loc) · 1.6 KB
/
TEST_CONTAINER-docker-build-and-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
name: TEST CONTAINER - Build and push Docker test image to Github packages
on:
workflow_dispatch:
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/sympoll-group-service-test
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Packages
run: echo "${{ secrets.PACKAGE_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Get current date
id: date
run: echo "::set-output name=DATE::$(date +'%d.%m.%Y')"
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: ~/.docker/builder
key: ${{ runner.os }}-build-${{ github.sha }} # Cache key based on OS and commit SHA
restore-keys: | # Check for existing cache based on previous builds with same OS and SHA
${{ runner.os }}-build-
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.IMAGE_NAME }}:${{ steps.date.outputs.DATE }}
${{ env.IMAGE_NAME }}:latest
cache-from: type=gha,key=${{ runner.os }}-build-${{ github.sha }} # Use cached layers based on commit SHA
cache-to: type=gha,mode=max # Enable caching to GitHub Actions