-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (55 loc) · 2.04 KB
/
build.yaml
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
on:
push:
branches:
- main
workflow_dispatch:
jobs:
find-subfolders:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Find subfolders to build
id: find
# List the two subdirectories under the src directory, trim src/ off the front of
# the path, and turn it into a json array for easier parsing in the next step.
# Like: ["fabric-runtime/1.2","fabric-runtime/1.3"]
run: |
SUBFOLDERS=$(find src -mindepth 2 -maxdepth 2 -type d | sed 's|^src/||' | jq --raw-input --slurp --compact-output 'split("\n")')
echo "Found subfolders: $SUBFOLDERS"
echo "SUBFOLDERS=$SUBFOLDERS" >> $GITHUB_ENV
outputs:
subfolders: ${{ env.SUBFOLDERS }}
build:
runs-on: ubuntu-latest
needs: find-subfolders
strategy:
matrix:
subfolder: ${{ fromJson(needs.find-subfolders.outputs.subfolders) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Parse out the image name and tag
id: parse
run: |
# The first part is the image name
IMAGE_NAME=$(echo ${{ matrix.subfolder }} | cut -d / -f 1)
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
# And the second part is the image tag
IMAGE_TAG=$(echo ${{ matrix.subfolder }} | cut -d / -f 2)
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
- name: Build images
uses: devcontainers/[email protected]
# Options: https://github.com/devcontainers/ci/blob/main/action.yml
with:
imageName: ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}
cacheFrom: ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}
imageTag: ${{ env.IMAGE_TAG }}
push: always
subFolder: src/${{ matrix.subfolder }}