-
Notifications
You must be signed in to change notification settings - Fork 3
58 lines (48 loc) · 1.63 KB
/
build-images.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
name: Build & Publish Docker Images
on:
push:
branches:
- alpha
jobs:
#
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #
website-frontend:
name: frontend (NextJS)
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: read
packages: write
steps:
- name: Set module key
run: |
echo "MODULE_KEY=frontend" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@main
- name: Calculate module SHA256 hash
run: |
find "./${{ env.MODULE_KEY }}" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1 > ${{ env.MODULE_KEY }}.hash
echo "SHA256_HASH=$(cat ${{ env.MODULE_KEY }}.hash)" >> $GITHUB_ENV
- name: Fetch hash cache
uses: actions/cache@v4
id: cache
with:
path: ${{ env.MODULE_KEY }}.hash
key: ${{ github.ref_name }}-${{ env.MODULE_KEY }}-${{ env.SHA256_HASH }}
- name: Login to GitHub Container Registry
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@master
with:
push: true
context: ./${{ env.MODULE_KEY }}
file: ./${{ env.MODULE_KEY }}/Dockerfile
tags: ghcr.io/carrismetropolitana/website-${{ env.MODULE_KEY }}:${{ github.ref_name }}