Skip to content

Commit 9848705

Browse files
committed
Added Github action for docker build and push to ghcr
1 parent 95477c3 commit 9848705

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: docker-image-push
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
on:
8+
push:
9+
tags:
10+
- 'v*'
11+
12+
env:
13+
# Use docker.io for Docker Hub if empty
14+
REGISTRY: ghcr.io
15+
# github.repository as <account>/<repo>
16+
IMAGE_NAME: azun/external-dns
17+
18+
jobs:
19+
build:
20+
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v2
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v2
32+
with:
33+
go-version: 1.17
34+
id: go
35+
36+
# Login against a Docker registry except on PR
37+
# https://github.com/docker/login-action
38+
- name: Log into registry ${{ env.REGISTRY }}
39+
if: github.event_name != 'pull_request'
40+
uses: docker/login-action@v1
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
# Extract metadata (tags, labels) for Docker
47+
# https://github.com/docker/metadata-action
48+
- name: Extract Docker metadata
49+
id: meta
50+
uses: docker/metadata-action@v3
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
tags: |
54+
type=ref,event=branch
55+
type=ref,event=pr
56+
type=semver,pattern={{version}}
57+
type=semver,pattern={{major}}.{{minor}}
58+
59+
# Build and push Docker image with Buildx (don't push on PR)
60+
# https://github.com/docker/build-push-action
61+
- name: Build and push Docker image
62+
uses: docker/build-push-action@v2
63+
with:
64+
context: .
65+
build-args: |
66+
ARCH=amd64
67+
push: ${{ github.event_name != 'pull_request' }}
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)