-
-
Notifications
You must be signed in to change notification settings - Fork 29
62 lines (56 loc) · 2.18 KB
/
docker.yml
File metadata and controls
62 lines (56 loc) · 2.18 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
name: 🐳 Publish Docker image
on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# Check whether the Docker credentials are available as secrets. If both are set, then set a boolean flag and export it to the environment.
- name: Check Docker credentials
run: |
if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "::notice title=Docker credentials are not set.::If you want to run this job on a PR from a fork, you need to set the DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets in the repository settings."
echo "DOCKER_CREDENTIALS_SET=false" >> $GITHUB_ENV
else
echo "::notice title=Docker credentials are set.::The subsequent steps will run."
echo "DOCKER_CREDENTIALS_SET=true" >> $GITHUB_ENV
fi
- name: Login to Docker Hub
if: env.DOCKER_CREDENTIALS_SET == 'true'
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
if: env.DOCKER_CREDENTIALS_SET == 'true'
id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/mqt-bench
- name: Build and push Docker image
if: env.DOCKER_CREDENTIALS_SET == 'true'
id: push
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}