From c4ace06f373b56581ed28f70cb8655bf21c9c3cd Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 13:47:20 -0600 Subject: [PATCH 01/13] add dependabot for docker --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c3844ac --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "docker" + directory: "meat-runner-22.04/" + schedule: + interval: "daily" From ab9b1069a43313043faa76f1aabff08d18196247 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 14:36:18 -0600 Subject: [PATCH 02/13] move meat-runner-22.04 into images folder --- {meat-runner-22.04 => images/meat-runner-22.04}/dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {meat-runner-22.04 => images/meat-runner-22.04}/dockerfile (100%) diff --git a/meat-runner-22.04/dockerfile b/images/meat-runner-22.04/dockerfile similarity index 100% rename from meat-runner-22.04/dockerfile rename to images/meat-runner-22.04/dockerfile From e26bff82fd25249dc316fccf25a3e92ed34bb176 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 14:36:54 -0600 Subject: [PATCH 03/13] create pr workflow for testing docker image run --- .github/workflows/pr.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..01915f7 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,36 @@ +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)}} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set Image Name output + run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[0])")" >> $GITHUB_OUTPUT + id: set_image_name + + - name: Set up Docker + uses: docker/setup-buildx-action@v1 + + - name: Build Docker image + run: docker build -t ${{ steps.set_image_name.outputs.image_name }}:latest ${{ matrix.image_folder }} + + - name: Check build status + run: docker run --rm ${{ steps.set_image_name.outputs.image_name }}:latest From 55fe7f0928e2f4c054149fe34802d987f3411aba Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 14:37:14 -0600 Subject: [PATCH 04/13] create create_matrix workflow for parsing images folder --- .github/workflows/create_matrix.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/create_matrix.yml diff --git a/.github/workflows/create_matrix.yml b/.github/workflows/create_matrix.yml new file mode 100644 index 0000000..5e29957 --- /dev/null +++ b/.github/workflows/create_matrix.yml @@ -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/checkout@v4.1.1 + - id: set-matrix + run: | + echo "matrix=$(ls -d ${{ inputs.image_directory }}/* | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT From e5ed2a808f0d806b500c5db340ecd1b808e8c956 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 14:41:27 -0600 Subject: [PATCH 05/13] fix context path for build --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 01915f7..e88bce4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -30,7 +30,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Build Docker image - run: docker build -t ${{ steps.set_image_name.outputs.image_name }}:latest ${{ matrix.image_folder }} + run: docker build -t ${{ steps.set_image_name.outputs.image_name }}:latest ${{ matrix.image_folder }}/. - name: Check build status run: docker run --rm ${{ steps.set_image_name.outputs.image_name }}:latest From a07895b1a8bcd8d67991b04516eca40bf4d62e3d Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 14:42:46 -0600 Subject: [PATCH 06/13] add merge.yml workflow for deploying package to ghcr --- .github/workflows/merge.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/merge.yml diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 0000000..d49decc --- /dev/null +++ b/.github/workflows/merge.yml @@ -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/checkout@v2 + + - name: Set Image Name output + run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[0])")" >> $GITHUB_OUTPUT + id: set_image_name + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - 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@v2 + with: + context: ${{ matrix.image_folder }}/. + push: true + tags: ghcr.io/${{ github.repository_owner }}/${{ steps.set_image_name.outputs }}:${{ github.sha }} From 3633752c11fadb5181e0d5c9036d23f5f188ed21 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 14:46:13 -0600 Subject: [PATCH 07/13] fix path dependabot --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c3844ac..9cd2ca3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,6 @@ version: 2 updates: - package-ecosystem: "docker" - directory: "meat-runner-22.04/" + directory: "images/meat-runner-22.04/" schedule: interval: "daily" From f8dc7c55fac0e043de46fc3bbe922c7c7a5574b8 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 14:50:25 -0600 Subject: [PATCH 08/13] fix array to use lookback index in image name split --- .github/workflows/merge.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index d49decc..f03be0c 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v2 - name: Set Image Name output - run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[0])")" >> $GITHUB_OUTPUT + run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[-1])")" >> $GITHUB_OUTPUT id: set_image_name - name: Set up Docker Buildx diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e88bce4..5b6ca4a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v2 - name: Set Image Name output - run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[0])")" >> $GITHUB_OUTPUT + run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[-1])")" >> $GITHUB_OUTPUT id: set_image_name - name: Set up Docker From 79f39cb20e76b42ed886958a20eaedfb016b79c3 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 15:08:55 -0600 Subject: [PATCH 09/13] add docker build push to github actions --- .github/workflows/pr.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5b6ca4a..e2f0fd8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -27,10 +27,16 @@ jobs: id: set_image_name - name: Set up Docker - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - - name: Build Docker image - run: docker build -t ${{ steps.set_image_name.outputs.image_name }}:latest ${{ matrix.image_folder }}/. + - name: Build and push to GHA + uses: docker/build-push-action@v5 + with: + context: ${{ matrix.image_folder }}/. + push: true + tags: synapsestudios/${{ 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 ${{ steps.set_image_name.outputs.image_name }}:latest + run: docker run --rm synapsestudios/${{ steps.set_image_name.outputs.image_name }}:latest From 74a483258db608485cbea271bdc63481590e62b7 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 15:27:33 -0600 Subject: [PATCH 10/13] remove registry name from tags in pr --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e2f0fd8..b405096 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,7 +34,7 @@ jobs: with: context: ${{ matrix.image_folder }}/. push: true - tags: synapsestudios/${{ steps.set_image_name.outputs.image_name }}:latest + tags: ${{ steps.set_image_name.outputs.image_name }}:latest cache-from: type=gha cache-to: type=gha,mode=max From 1d709effdbed14d76f952702010d12b76fa7e73e Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 15:31:04 -0600 Subject: [PATCH 11/13] remove push and registry name from run --- .github/workflows/pr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b405096..7aa0175 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -33,10 +33,9 @@ jobs: uses: docker/build-push-action@v5 with: context: ${{ matrix.image_folder }}/. - push: true tags: ${{ 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 synapsestudios/${{ steps.set_image_name.outputs.image_name }}:latest + run: docker run --rm ${{ steps.set_image_name.outputs.image_name }}:latest From 981395c1f259dfcdbb86b1b55b4fc163dc37cf08 Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 15:47:23 -0600 Subject: [PATCH 12/13] add registry service to allow docker to run --- .github/workflows/pr.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7aa0175..6c0afa3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -18,6 +18,12 @@ jobs: matrix: image_folder: ${{fromJson(needs.create_matrix.outputs.matrix)}} + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: - name: Checkout code uses: actions/checkout@v2 @@ -28,14 +34,17 @@ jobs: - 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 }}/. - tags: ${{ steps.set_image_name.outputs.image_name }}:latest + 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 ${{ steps.set_image_name.outputs.image_name }}:latest + run: docker run --rm localhost:5000/${{ steps.set_image_name.outputs.image_name }}:latest From b72315128c4f55b83123e802112a6342d63865bb Mon Sep 17 00:00:00 2001 From: Devin Lauderdale Date: Tue, 27 Feb 2024 16:18:34 -0600 Subject: [PATCH 13/13] bump action versions --- .github/workflows/merge.yml | 6 +++--- .github/workflows/pr.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index f03be0c..1d84ecc 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -19,14 +19,14 @@ jobs: image_folder: ${{fromJson(needs.create_matrix.outputs.matrix)}} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4.1.1 - 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@v1 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -36,7 +36,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: ${{ matrix.image_folder }}/. push: true diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6c0afa3..d492228 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4.1.1 - name: Set Image Name output run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[-1])")" >> $GITHUB_OUTPUT