This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
forked from JasonN3/build-container-installer
-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (71 loc) · 2.11 KB
/
build-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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
name: Create Container
on:
pull_request:
branches:
- main
paths:
- 'Dockerfile'
push:
branches:
- main
paths:
- 'Dockerfile'
workflow_dispatch:
env:
IMAGE_NAME: isogenerator
IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}"
jobs:
push-image:
name: Build and push image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action
uses: actions/checkout@v3
# Build metadata
- name: Image Metadata
uses: docker/metadata-action@v4
id: meta
with:
images: |
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/main/README.md
org.opencontainers.image.description=A container image for generating Universal Blue ISO files
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Image
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
check:
name: Check build successful
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
needs: [push-image]
steps:
- name: Exit on failure
if: ${{ needs.push-image.result == 'failure' || needs.push-image.result == 'skipped' }}
shell: bash
run: exit 1
- name: Exit
shell: bash
run: exit 0