Repository navigation
65 lines (58 loc) · 2.24 KB
/
Copy pathdocker.yml
File metadata and controls
65 lines (58 loc) · 2.24 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
name: 🐳 Publish Docker image
on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"
permissions: {}
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
# 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@dbcb813823bdd20940b903addbd779551569679f # v4.6.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@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.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@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}