-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (125 loc) · 4.06 KB
/
build-image-manual.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: build-image-manual
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
workflow_dispatch:
inputs:
project:
description: 'Project name'
required: true
type: choice
options:
- coder-development
- epay
- dujiaoka
- opsutils
- tidb-toolkit
- jenkins
- subconverter
- frps
- frpc
- vmianqian
- tokenpay
- n8n
- bepusdt
- http-dump
- kubectl
- radiance-bot
- nezha
- weserv
- media-unlock
- sniproxy
- xboard
- ws-scrcpy
- excalidraw
- linkstack
- firefox
- mitmproxy
- redroid
- nginx-proxy-manager
- authelia
- webdav-backup
tag:
description: 'Image tag'
env:
PROJECT_NAME: ${{ github.event.inputs.project }}
# github.repository as <account>/<repo>
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set tag
id: tag
run: |
tag=""
dockerfile_version=$(cat ${{ env.PROJECT_NAME }}/Dockerfile | awk '{if($1~"LABEL" && $2=="VERSION")print $3}')
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
tag=${{ github.event.inputs.tag }}
elif [[ -n "${dockerfile_version}" ]]; then
tag=${dockerfile_version}
else
echo "Image tag can not be null!"
exit 1
fi
docker_image_name=${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT_NAME }}
tags=${docker_image_name}:${tag},${docker_image_name}:latest
echo "IMAGE_TAGS=${tags}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ env.PROJECT_NAME }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ env.PROJECT_NAME }}-
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
context: ${{ env.PROJECT_NAME }}
push: true
tags: ${{ env.IMAGE_TAGS }}
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Check readme existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "${{ env.PROJECT_NAME }}/README.md"
- name: Sync README.md to Docker Hub
if: steps.check_files.outputs.files_exists == 'true'
uses: ms-jpq/sync-dockerhub-readme@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT_NAME }}
readme: "${{ env.PROJECT_NAME }}/README.md"