-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (183 loc) · 6.11 KB
/
docker-branch.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Docker-Build-Push
# Run this workflow every time a new commit pushed to docker-build branch
on:
push:
branches:
- docker-build
workflow_dispatch:
inputs:
deployEnvironment:
description: 'Deployment Environment'
required: true
default: 'dev'
logLevel:
description: 'The Logging Level'
required: false
default: 'low'
jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
super-lint:
# Name the Job
name: Lint code base
# Set the type of machine to run on
runs-on: ubuntu-latest
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'
# Runs the Super-Linter action
- name: Run Super-Linter
uses: github/[email protected]
env:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: .*github/workflows/*.yaml
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-test:
name: Build test image and test
runs-on: ubuntu-latest
needs: super-lint
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
-
name: Build Test Image
env:
DOCKER_CONTENT_TRUST=1
- run: |
sed "s/#HEALTHCHECK/HEALTHCHECK/" -i Dockerfile
docker buildx build -t testimage --load .
-
name: Scan Test Iamge
uses: Azure/container-scan@v0
with:
image-name: testimage
buildx:
name: Build and push
runs-on: ubuntu-latest
needs: build-test
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
-
name: Setup Path
run: |
echo "${GITHUB_WORKSPACE}"/travis-helpers >> $GITHUB_PATH
echo ${HOME}/.local/bin >> $GITHUB_PATH
-
name: Install helper dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install --upgrade docker natsort bs4
-
name: Get Label Info
id: docklabel
run: |
INFO=README.md
if [ -f "$INFO" ]; then
echo "Reading $INFO..."
NAME="$(head -1 README.md| cut -d' ' -f2)"
DESC="$(head -2 README.md | tail -n1)"
else
echo "$INFO not found"
DESC="None"
fi
[ $EDGE == "yes" ] && _e="-e"
APK_VER="$(date +%d%m%g)"
ALP_VER="$(version.py -b $_e)"
echo "$ALP_VER, $APK is $APK_VER"
echo "name: $NAME"
echo "desc: $DESC"
echo "::set-output name=apk_ver::$APK_VER"
echo "::set-output name=alp_ver::$ALP_VER"
echo "::set-output name=ver::$APK_VER-alpine$ALP_VER"
echo "::set-output name=name-label::$NAME"
echo "::set-output name=desc::$DESC"
echo "::set-output name=plats::$PLATS"
echo "::set-output name=img::$IMAGE_NAME"
echo "::set-output name=date::$(date -u +'%Y-%m-%d %H:%M:%S')"
echo "::set-output name=sha::$GITHUB_SHA"
echo "::set-output name=repo::$GITHUB_REPOSITORY"
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ steps.docklabel.outputs.plats }}
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
-
name: Available Platforms
run: echo ${{ steps.buildx.outputs.platforms }}
-
name: Uncomment Healthcheck
run: sed "s/#HEALTHCHECK/HEALTHCHECK/" -i Dockerfile
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Show Labels
run: |
echo "Alpine Ver: ${{ steps.docklabel.outputs.alp_ver }}"
echo "Main Apk: $APK"
echo "Apk Ver: ${{ steps.docklabel.outputs.apk_ver }}"
echo "Tag Ver: ${{ steps.docklabel.outputs.ver }}"
echo "Name: ${{ steps.docklabel.outputs.name-label }}"
echo "Desc: ${{ steps.docklabel.outputs.desc }}"
echo "Platforms: ${{ steps.docklabel.outputs.plats }}"
echo "Image Name: ${{ steps.docklabel.outputs.img }}"
echo "Date: ${{ steps.docklabel.outputs.date }}"
echo "Sha: ${{ steps.docklabel.outputs.sha }}"
echo "Repo: ${{ steps.docklabel.outputs.repo }}"
-
name: Build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: ${{ steps.docklabel.outputs.plats }}
push: true
tags: |
${{ steps.docklabel.outputs.img }}:${{ steps.docklabel.outputs.ver }}
${{ steps.docklabel.outputs.img }}
labels: |
org.label-schema.schema-version=1.0
org.label-schema.build-date=${{ steps.docklabel.outputs.date }}
org.label-schema.version=${{ steps.docklabel.outputs.ver }}
org.label-schema.vcs-ref=${{ steps.docklabel.outputs.sha }}
org.label-schema.vcs-url=https://github.com/${{ steps.docklabel.outputs.repo }}
org.label-schema.name=${{ steps.docklabel.outputs.name-label }}
org.label-schema.version=${{ steps.docklabel.outputs.apk_ver }}
org.label-schema.description=${{ steps.docklabel.outputs.desc }}
alpine-version=${{ steps.docklabel.outputs.alp_ver }}
env:
PLATS: linux/386,linux/amd64,linux/ppc64le,linux/s390x,linux/arm/v7,linux/arm64
IMAGE_NAME: a16bitsysop/olefy
APK: python
# yes to get edge version of APK
EDGE: no
# in github secrets for repo
# DOCKER_USERNANE
# DOCKER_PASSWORD
# WEBHOOK