-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (44 loc) · 1.32 KB
/
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
name: Build
on:
workflow_call:
inputs:
latest:
description: "If the container should be tagged as latest."
type: boolean
required: false
default: false
push:
description: "If the built container should be pushed."
type: boolean
required: false
default: false
jobs:
build:
name: Build docker image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Container Registry
if: ${{ inputs.push }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create SHA Container Tag
id: sha_tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "::set-output name=tag::$tag"
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: ${{ inputs.push }}
tags: |
ghcr.io/abandontech/abandontechsite:${{ steps.sha_tag.outputs.tag }}
${{ inputs.latest && 'ghcr.io/abandontech/abandontechsite:latest' || '' }}