-
-
Notifications
You must be signed in to change notification settings - Fork 76
56 lines (49 loc) · 1.78 KB
/
publish-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
name: Build and publish the production container image to the GitHub Registry
# Run this workflow when new releases are created
on:
release:
types: [published]
env:
IMAGE_NAME: imap-backup
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
REGISTRY: ghcr.io/${{ github.repository_owner }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets 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: Get the latest tag
run: |
echo "GIT_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Build Image
# https://github.com/marketplace/actions/buildah-build
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: latest ${{ github.sha }} ${{ env.GIT_TAG }}
extra-args: |
--ignorefile ./container/.containerignore
containerfiles: |
./container/Containerfile
labels: |
${{ env.IMAGE_NAME }}:latest
# Check that imap-backup runs
- name: Test Image
run: podman run ${{ env.IMAGE_NAME }}:latest imap-backup help | grep 'Commands:'
- name: Publish Image
# https://github.com/marketplace/actions/push-to-registry
id: push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}