-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (66 loc) · 2.01 KB
/
build-and-publish-container-image.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
name: Create and publish k8s workbench container image
on:
push:
branches:
- "**"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
env:
REGISTRY: ghcr.io
IMAGE_NAME: harbor-day2-operator
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
- uses: ricardochaves/python-lint@v1.4.0
with:
use-pylint: false
use-flake8: false
use-black: false
use-mypy: false
use-isort: false
- name: Log in to the container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for container
id: meta
uses: docker/metadata-action@35e9aff4f5d665b5aa8a8f2adffaf8a1b5f49cc0
with:
images: ${{ env.REGISTRY }}/steadforce/steadops/workbenches/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build container image for tests
uses: docker/build-push-action@4fad532b9fdbfb80f436784834374a1c11834153
with:
context: .
push: false
tags: ${{ env.IMAGE_NAME }}:test
- name: Test harbor tool
run: |
docker run --rm ${{ env.IMAGE_NAME }}:test /usr/local/harbor --help
- name: Tag and push tested container image
uses: docker/build-push-action@4fad532b9fdbfb80f436784834374a1c11834153
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}