-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (104 loc) · 5.4 KB
/
alpine.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: GitHub Actions Continuous Delivery (Alpine)
on:
push:
branches:
- main
tags:
- "*"
schedule:
# Automatically run on every Day
- cron: "0 17 * * *"
workflow_dispatch:
jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.0
with:
# [Required] Access token with `workflow` scope.
token: ${{ secrets.WORKFLOW_SECRET }}
- name: Set env variables
run: |
echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "http_proxy=${http_proxy}" >> $GITHUB_ENV
echo "no_proxy=${no_proxy}" >> $GITHUB_ENV
- # Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3.2.0
- # https://github.com/docker/setup-buildx-action/issues/57#issuecomment-1059657292
# https://github.com/docker/buildx/issues/136#issuecomment-550205439
# docker buildx create --driver-opt env.http_proxy=$http_proxy --driver-opt env.https_proxy=$https_proxy --driver-opt '"env.no_proxy='$no_proxy'"'
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.6.1
with:
buildkitd-config: .github/buildkitd.toml
driver-opts: |
env.http_proxy=${{ env.http_proxy }}
env.https_proxy=${{ env.http_proxy }}
env.no_proxy=${{ env.no_proxy }}
- name: Login to DockerHub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
name=snowdreamtech/helloworld,enable=true
name=ghcr.io/snowdreamtech/helloworld,enable=true
flavor: |
latest=false
prefix=
suffix=
tags: |
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
type=edge,enable=true,priority=700,prefix=,suffix=,branch=dev
type=raw,enable={{is_default_branch}},priority=200,prefix=,suffix=,value=latest
type=raw,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=200,prefix=,suffix=,value=latest
type=pep440,enable=true,priority=900,prefix=,suffix=,pattern={{version}}
type=pep440,enable=true,priority=900,prefix=,suffix=,pattern={{major}}.{{minor}}
type=pep440,enable=${{ !startsWith(github.ref, 'refs/tags/v0.') && !startsWith(github.ref, 'refs/tags/0.') }},priority=900,prefix=,suffix=,pattern={{major}}
type=ref,enable=true,priority=600,prefix=,suffix=-alpine,event=branch
type=edge,enable=true,priority=700,prefix=,suffix=-alpine,branch=dev
type=raw,enable={{is_default_branch}},priority=200,prefix=,suffix=,value=alpine
type=raw,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=200,prefix=,suffix=,value=alpine
type=pep440,enable=true,priority=900,prefix=,suffix=-alpine,pattern={{version}}
type=pep440,enable=true,priority=900,prefix=,suffix=-alpine,pattern={{major}}.{{minor}}
type=pep440,enable=${{ !startsWith(github.ref, 'refs/tags/v0.') && !startsWith(github.ref, 'refs/tags/0.') }},priority=900,prefix=,suffix=-alpine,pattern={{major}}
type=ref,enable=true,priority=600,prefix=,suffix=-alpine3.20,event=branch
type=edge,enable=true,priority=700,prefix=,suffix=-alpine3.20,branch=dev
type=raw,enable={{is_default_branch}},priority=200,prefix=,suffix=,value=alpine3.20
type=raw,enable=${{ startsWith(github.ref, 'refs/tags/') }},priority=200,prefix=,suffix=,value=alpine3.20
type=pep440,enable=true,priority=900,prefix=,suffix=-alpine3.20,pattern={{version}}
type=pep440,enable=true,priority=900,prefix=,suffix=-alpine3.20,pattern={{major}}.{{minor}}
type=pep440,enable=${{ !startsWith(github.ref, 'refs/tags/v0.') && !startsWith(github.ref, 'refs/tags/0.') }},priority=900,prefix=,suffix=-alpine3.20,pattern={{major}}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- name: Build and push
uses: docker/build-push-action@v6.7.0
with:
context: alpine
build-args: |
http_proxy=${{ env.http_proxy }}
https_proxy=${{ env.http_proxy }}
env.no_proxy=${{ env.no_proxy }}
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max