-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (72 loc) · 2.63 KB
/
docker-images.yml
File metadata and controls
77 lines (72 loc) · 2.63 KB
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 Image Builder
on:
workflow_dispatch:
schedule:
# Run once a week on Fridays
- cron: "0 0 * * FRI"
pull_request:
paths:
- ".github/docker/Dockerfile"
- ".github/workflows/docker-images.yml"
push:
branches:
- main
paths:
- ".github/docker/Dockerfile"
- ".github/workflows/docker-images.yml"
jobs:
build:
runs-on: ${{ matrix.IMAGE.RUNNER }}
timeout-minutes: 10
permissions:
contents: read
packages: write
id-token: write
attestations: write
strategy:
fail-fast: false
matrix:
IMAGE:
- {
TAG_NAME: "archlinux:latest",
DOCKER_PLATFORM: "linux/loong64",
DOCKERFILE_PATH: ".github/docker",
RUNNER: "ubuntu-latest",
}
name: Build Archlinux docker image
steps:
- uses: actions/checkout@v4.2.2
with:
persist-credentials: false
- name: Pull existing image
run: docker pull ghcr.io/${{ github.repository_owner }}/${{ matrix.IMAGE.TAG_NAME }} || true
if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'
- name: Setup environment variables
shell: bash
id: image-name
run: |
IMAGE_NAME=$(echo "${{ matrix.IMAGE.TAG_NAME }}" | cut -d ':' -f 1)
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
with:
cache-binary: false
- name: Login to ghcr.io
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
- name: Build docker image
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6.17.0
id: docker-build
with:
context: ${{ matrix.IMAGE.DOCKERFILE_PATH }}
cache-from: ghcr.io/${{ github.repository_owner }}/${{ matrix.IMAGE.TAG_NAME }}
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.IMAGE.TAG_NAME }}
platforms: ${{ matrix.IMAGE.DOCKER_PLATFORM }}
pull: true
push: ${{ (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }}