-
Notifications
You must be signed in to change notification settings - Fork 57
58 lines (56 loc) · 2.62 KB
/
astarte-build-workflow.yaml
File metadata and controls
58 lines (56 loc) · 2.62 KB
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: Astarte build
on:
workflow_call:
jobs:
astarte-build:
name: Astarte build
runs-on: ubuntu-24.04
strategy:
matrix:
app:
- name: astarte-housekeeping
service: astarte_housekeeping
tag: astarte/astarte_housekeeping:snapshot
- name: astarte-realm-management
service: astarte_realm_management
tag: astarte/astarte_realm_management:snapshot
- name: astarte-pairing
service: astarte_pairing
tag: astarte/astarte_pairing:snapshot
- name: astarte-appengine-api
service: astarte_appengine_api
tag: astarte/astarte_appengine_api:snapshot
- name: astarte-data-updater-plant
service: astarte_data_updater_plant
tag: astarte/astarte_data_updater_plant:snapshot
- name: astarte-trigger-engine
service: astarte_trigger_engine
tag: astarte/astarte_trigger_engine:snapshot
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build branch slug env variable (job-scoped)
run: |
# Slugify branch/tag name for Docker tag safety and consistency
echo "BRANCH_SLUG=$(echo "${GITHUB_REF_NAME}" | sha1sum | cut -f 1 -d ' ')" >> $GITHUB_ENV
# Build and save each Astarte app Docker image in parallel
# and use build cache from GitHub Container Registry (isolated per app and branch to avoid cache thrashing)
- name: Build ${{ matrix.app.name }}
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
with:
context: .
build-args: SERVICE=${{ matrix.app.service }}
push: false
cache-from: type=gha,scope=${{ matrix.app.name }}-${{ env.BRANCH_SLUG }}
cache-to: type=gha,mode=max,scope=${{ matrix.app.name }}-${{ env.BRANCH_SLUG }}
outputs: type=docker,dest=${{ runner.temp }}/${{ matrix.app.name }}.tar
tags: ${{ matrix.app.tag }}
# Upload the built image as an artifact to be shared with other workflows
# we use the commit SHA to avoid collisions between different workflow runs
- name: Upload ${{ matrix.app.name }} artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
# Give each image a unique artifact name to avoid clashes across matrix jobs
name: astarte-images-${{ matrix.app.name }}
path: ${{ runner.temp }}/${{ matrix.app.name }}.tar