-
-
Notifications
You must be signed in to change notification settings - Fork 209
59 lines (50 loc) · 1.8 KB
/
container.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
env:
IMAGE_TAG: 20250213-1
on:
workflow_call:
outputs:
image:
description: "The build image"
value: ${{ jobs.build-container.outputs.image }}
image_options:
description: "The options to use with the image"
value: --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined --privileged
jobs:
build-container:
name: Create build container
runs-on: ubuntu-latest
outputs:
image: ${{ steps.check.outputs.image }}
steps:
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Check if image already exists on GHCR
id: check
run: |
ACTOR="${{ github.actor }}"
OWNER="${{ github.repository_owner }}"
image_actor="ghcr.io/${ACTOR,,}/xdg-desktop-portal:${{ env.IMAGE_TAG }}"
image_owner="ghcr.io/${OWNER,,}/xdg-desktop-portal:${{ env.IMAGE_TAG }}"
if docker manifest inspect "${image_owner}" >/dev/null ; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "image=${image_owner}" >> "$GITHUB_OUTPUT"
exit 0
fi
if docker manifest inspect "${image_actor}" >/dev/null ; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "image=${image_actor}" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "image=${image_owner}" >> "$GITHUB_OUTPUT"
- name: Build and push
if: ${{ steps.check.outputs.exists == 'false' }}
uses: docker/build-push-action@v5
with:
push: true
file: .github/workflows/Containerfile
tags: ${{ steps.check.outputs.image }}