forked from nickvanw/infping
-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (65 loc) · 2.31 KB
/
docker.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: docker
on:
push:
branches: ['master']
pull_request:
branches: ['master']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: tricks
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
echo '${{ github.ref }}' | awk -F\, '{ split($0, v, "/"); sub(/^v/, "", v[3]); print "VERSION=" v[3] }' >>${GITHUB_ENV}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log in into the registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
if: ${{ github.event_name = 'push' && startsWith(github.ref, 'refs/tags/v') }}
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
- name: Build Docker image
uses: docker/build-push-action@v5
if: ${{ github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v') }}
with:
context: .
file: ./docker/Dockerfile
push: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Build and push Docker image with Buildx (don't push on PR)
- name: Build and push Docker image
uses: docker/build-push-action@v5
if: ${{ github.event_name = 'push' && startsWith(github.ref, 'refs/tags/v') }}
with:
context: .
file: ./docker/Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7