-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (64 loc) · 2.44 KB
/
buildAndPushContainer.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
# This YAML file contains a GitHub Actions workflow that builds and deploys a Docker image to Docker Hub.
# The workflow is triggered on push events to the main branch and runs on an Ubuntu latest runner.
# It checks out the repository, sets up QEMU and Docker Buildx, logs in to Docker Hub, builds and pushes the Docker image,
# and logs out from Docker Hub.
name: Build and Push Docker Image
on:
push:
branches:
- main
pull_request:
branches: [ "**" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Docker Setup QEMU
uses: docker/[email protected]
- name: Docker Setup Buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
if: ${{ github.event_name != 'pull_request' }}
uses: docker/[email protected]
with:
context: ./supplychain/container/
file: ./supplychain/container/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ntdominikpabst/it-tage-ffm-2023-devops:latest
ntdominikpabst/it-tage-ffm-2023-devops:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Docker image for pull request
if: ${{ github.event_name == 'pull_request' }}
uses: docker/[email protected]
with:
context: ./supplychain/container/
file: ./supplychain/container/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ntdominikpabst/it-tage-ffm-2023-devops:${{ github.sha }}_PR${{ github.event.number }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Docker Scout
id: docker-scout
if: ${{ github.event_name == 'pull_request' }}
uses: docker/scout-action@v1
with:
command: compare
image: ntdominikpabst/it-tage-ffm-2023-devops:${{ github.sha }}_PR${{ github.event.number }}
to-latest: true
ignore-base: true
ignore-unchanged: true
only-severities: critical,high
write-comment: true
github-token: ${{ secrets.GH_TOKEN }}