-
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.
Merge pull request #4 from synapsestudios/2/add-github-actions-for-de…
…ployment-to-ghcr 2/add GitHub actions for deployment to ghcr
- Loading branch information
Showing
5 changed files
with
124 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,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "docker" | ||
directory: "images/meat-runner-22.04/" | ||
schedule: | ||
interval: "daily" |
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,25 @@ | ||
name: Create Matrix | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image_directory: | ||
description: "Directory that contains image directories e.g. images/image1, images/image2, ..." | ||
required: true | ||
type: string | ||
outputs: | ||
matrix: | ||
description: "Matrix of image directories" | ||
value: ${{ jobs.create_matrix.outputs.matrix }} | ||
|
||
jobs: | ||
create_matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
- id: set-matrix | ||
run: | | ||
echo "matrix=$(ls -d ${{ inputs.image_directory }}/* | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT |
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,43 @@ | ||
name: Merge to Main CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
create_matrix: | ||
uses: ./.github/workflows/create_matrix.yml | ||
with: | ||
image_directory: "./images" | ||
|
||
build-and-push: | ||
runs-on: ubuntu-latest | ||
needs: create_matrix | ||
strategy: | ||
matrix: | ||
image_folder: ${{fromJson(needs.create_matrix.outputs.matrix)}} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Set Image Name output | ||
run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[-1])")" >> $GITHUB_OUTPUT | ||
id: set_image_name | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ matrix.image_folder }}/. | ||
push: true | ||
tags: ghcr.io/${{ github.repository_owner }}/${{ steps.set_image_name.outputs }}:${{ github.sha }} |
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,50 @@ | ||
name: PR Build | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
create_matrix: | ||
uses: ./.github/workflows/create_matrix.yml | ||
with: | ||
image_directory: "./images" | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: create_matrix | ||
strategy: | ||
matrix: | ||
image_folder: ${{fromJson(needs.create_matrix.outputs.matrix)}} | ||
|
||
services: | ||
registry: | ||
image: registry:2 | ||
ports: | ||
- 5000:5000 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Set Image Name output | ||
run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[-1])")" >> $GITHUB_OUTPUT | ||
id: set_image_name | ||
|
||
- name: Set up Docker | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
driver-opts: network=host | ||
|
||
- name: Build and push to GHA | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ matrix.image_folder }}/. | ||
push: true | ||
tags: localhost:5000/${{ steps.set_image_name.outputs.image_name }}:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Check build status | ||
run: docker run --rm localhost:5000/${{ steps.set_image_name.outputs.image_name }}:latest |
File renamed without changes.