-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial action to build and push the image
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Editor configuration, see https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
insert_final_newline = true | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
find: | ||
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, and trim src/ off the front of the path | ||
# Like: fabric-runtime/1.2 | ||
run: find src -mindepth 2 -maxdepth 2 -type d | sed 's|^src/||' | ||
|
||
- name: Set outputs | ||
id: set-outputs | ||
# Output them with commas, like: fabric-runtime/1.2,fabric-runtime/1.3 | ||
run: echo "::set-output name=subfolders::$(echo "${{ steps.find.outputs.stdout }}" | tr '\n' ',')" | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
subfolder: ${{ steps.set-outputs.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 "::set-env name=IMAGE_NAME::$IMAGE_NAME" | ||
# And the second part is the image tag | ||
IMAGE_TAG=$(echo ${{ matrix.subfolder }} | cut -d / -f 2) | ||
echo "::set-env name=IMAGE_TAG::$IMAGE_TAG" | ||
- 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 }} |