-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (46 loc) · 1.49 KB
/
build-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
name: build image
on:
workflow_dispatch:
push:
branches:
- main
paths:
- Dockerfile
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
PLATFORMS: linux/arm/v7
jobs:
build-image:
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Retrieve image version
run: echo "IMAGE_VERSION=$(head -1 Dockerfile | grep -oP '(?<=caddy:).*?(?=-builder)')" >> $GITHUB_ENV
- name: Parse version ranges
run: |
echo "IMAGE_VERSION_MAJOR=$(echo $IMAGE_VERSION | cut -d '.' -f 1)" >> $GITHUB_ENV
echo "IMAGE_VERSION_MAJOR_MINOR=$(echo $IMAGE_VERSION | cut -d '.' -f 1,2)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
platforms: ${{ env.PLATFORMS }}
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}
${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION_MAJOR }}
${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION_MAJOR_MINOR }}
${{ env.IMAGE_NAME }}:latest