-
Notifications
You must be signed in to change notification settings - Fork 4
97 lines (82 loc) · 3.05 KB
/
docker-publish.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
name: Docker-ghcr
on:
push:
tags:
- "v*.*.*"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
jobs:
test:
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
check-latest: true
- name: Test
run: go test -v ./...
env:
TEST_DOCKER_PRIVATE_HOST: ${{ secrets.TEST_DOCKER_PRIVATE_HOST }}
TEST_DOCKER_PRIVATE_IMAGE: ${{ secrets.TEST_DOCKER_PRIVATE_IMAGE }}
TEST_DOCKER_PRIVATE_TAG: ${{ secrets.TEST_DOCKER_PRIVATE_TAG }}
TEST_DOCKER_PRIVATE_USERNAME: ${{ secrets.TEST_DOCKER_PRIVATE_USERNAME }}
TEST_DOCKER_PRIVATE_PASSWORD: ${{ secrets.TEST_DOCKER_PRIVATE_PASSWORD }}
TEST_DOCKER_PRIVATE_SKIP: ${{ vars.TEST_DOCKER_PRIVATE_SKIP }}
TEST_DOCKER_ECR_HOST: ${{ secrets.TEST_DOCKER_ECR_HOST }}
TEST_DOCKER_ECR_IMAGE: ${{ secrets.TEST_DOCKER_ECR_IMAGE }}
TEST_DOCKER_ECR_TAG: ${{ secrets.TEST_DOCKER_ECR_TAG }}
TEST_DOCKER_ECR_SKIP: ${{ vars.TEST_DOCKER_ECR_SKIP }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
docker-build-push:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
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
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# 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
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
- name: action-slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: Docker Publish - ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
fields: repo,message,author,eventName,took,job
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }} # required
if: always()