This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
generated from nicholaswilde/docker-template
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (108 loc) · 3.62 KB
/
ci.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
---
# The following secrets are required to push the images.
# DOCKERHUB_USERNAME
# DOCKERHUB_TOKEN
# CR_PAT
# QUAY_USERNAME
# QUAY_TOKEN
# The quay repository needs to be created first using the web interface and the
# robot needs to be given write access to it before pushing to it.
name: ci
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
description: 'Version'
# Default value if no value is explicitly provided
default: '0.1.0'
# Input has to be provided for the workflow to run
required: true
ls:
description: 'ls'
default: 'ls1'
required: true
jobs:
main:
runs-on: ubuntu-20.04
steps:
-
name: Get tag
run: echo "tag=${{ github.event.inputs.version }}-${{ github.event.inputs.ls }}" >> $GITHUB_ENV
-
name: Remove docker from the repo name
run: echo "repo_name=$(echo "${{ github.event.repository.name }}" | sed 's/[^-]*-//')" >> $GITHUB_ENV
-
name: Get current date
run: echo "date=$(date -u +%Y-%m-%dT%H%M%SZ)" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: image=moby/buildkit:master
-
name: Cache Docker layers
uses: actions/cache@v2.1.5
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
-
name: Login to Quay Registry
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2.3.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
build-args: |
BUILD_DATE=${{ env.date }}
VERSION=${{ github.event.inputs.version }}
tags: |
${{ github.repository_owner }}/${{ env.repo_name }}:latest
${{ github.repository_owner }}/${{ env.repo_name }}:${{ env.tag }}
ghcr.io/${{ github.repository_owner }}/${{ env.repo_name }}:latest
ghcr.io/${{ github.repository_owner }}/${{ env.repo_name }}:${{ env.tag }}
quay.io/${{ github.repository_owner }}/${{ env.repo_name }}:latest
quay.io/${{ github.repository_owner }}/${{ env.repo_name }}:${{ env.tag }}
-
name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.tag }}
release_name: ${{ env.tag }}
draft: false
prerelease: false