-
Notifications
You must be signed in to change notification settings - Fork 3
54 lines (51 loc) · 1.56 KB
/
build_and_push_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
54
name: Docker image build and push
on:
push:
branches:
- main
permissions:
packages: write
jobs:
clean-ghcr:
runs-on: ubuntu-latest
steps:
- name: determine repository name
run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
shell: bash
- name: prune untagged images older than 24 hours
uses: snok/container-retention-policy@v1
with:
image-names: ${{ env.REPOSITORY_NAME }}
cut-off: A day ago UTC
account-type: org
org-name: ${{ github.repository_owner }}'
untagged-only: true
token: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
steps:
- name: checkout source
uses: actions/checkout@v2
- name: set up QEMU for Docker buildx
uses: docker/setup-qemu-action@v1
- name: set up Docker buildx
uses: docker/setup-buildx-action@v1
- name: login to ghcr.io
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}
tags: latest
- name: build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: ${{ steps.meta.outputs.tags }}