-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (53 loc) · 2.06 KB
/
container_build.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
name: Create and publish a Docker image
# Configure this workflow to run every time a change is pushed to the main
# branch or any branch whose name starts with `release/` or any time a tag is
# created; this workflow is also run any time a GitHub release is published.
# The image will be given a tag which is based on the trigger.
on:
push:
branches: [main, 'release/**']
tags: ['*']
release:
types: [published]
# Set up the container image specification to be `quay.io/pbench/file-relay`.
env:
REGISTRY: quay.io
ORGANIZATION: pbench
IMAGE_NAME: file-relay
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Set the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_ROBOT_TOKEN }}
# Extract metadata from the Git reference and the GitHub event.
# Subsequent steps can reference the values via `steps.meta.outputs.<key>`.
# The `images` value provides the name for the container image which is
# used in tags and labels.
- name: Extract metadata (tags, labels) from Git for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}
# Build the container image based on the Dockerfile and the rest of the
# files found in the root of the Git checkout. If the build succeeds,
# the image is pushed to the registry indicated by the tags.
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
network: host
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}