-
Notifications
You must be signed in to change notification settings - Fork 12
74 lines (71 loc) · 2.72 KB
/
Copy pathmain.yml
File metadata and controls
74 lines (71 loc) · 2.72 KB
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
env:
CONTAINER_IMAGE_LATEST_TAG: githubchangeloggenerator/github-changelog-generator:latest
CONTAINER_IMAGE_RELEASE_TAG: githubchangeloggenerator/github-changelog-generator:${{ github.event.release.tag_name }}
DOCKER_BUILDX_PLATFORMS: linux/amd64,linux/arm64
name: Build the container image and eventually deploy it
on:
push:
pull_request:
release:
types: [created]
jobs:
build:
name: Lint the codebase, build and test the image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
- name: Super-Linter
uses: github/super-linter@v4.1.0
env:
ERROR_ON_MISSING_EXEC_BIT: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: .
VALIDATE_ALL_CODEBASE: true
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1.1.0
- name: Build the container image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: ${{ env.DOCKER_BUILDX_PLATFORMS }}
push: false
tags: ${{ env.CONTAINER_IMAGE_LATEST_TAG }}
deploy:
environment: Docker Hub
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'release' && github.event.action == 'created') }}
name: Deploy the container image
needs: build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1.1.0
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# This is to avoid duplicating the image building step
- if: ${{ github.event_name != 'release' }}
name: Set the CONTAINER_IMAGE_RELEASE_TAG environment variable
run: |
echo "CONTAINER_IMAGE_RELEASE_TAG=${CONTAINER_IMAGE_LATEST_TAG}" >> ${GITHUB_ENV}
- name: Build the container image for all the platforms and eventually push to Docker Hub (latest)
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: ${{ env.DOCKER_BUILDX_PLATFORMS }}
push: true
tags: ${{ env.CONTAINER_IMAGE_LATEST_TAG }},${{ env.CONTAINER_IMAGE_RELEASE_TAG }}
- name: Test the latest container image
shell: bash
run: docker run ${{ env.CONTAINER_IMAGE_LATEST_TAG }}
- name: Test the release container image
shell: bash
run: docker run ${{ env.CONTAINER_IMAGE_RELEASE_TAG }}