From f011775aa870704cc2858308c31100469900ceaf Mon Sep 17 00:00:00 2001 From: moonstar-x Date: Fri, 1 Nov 2024 03:18:35 -0500 Subject: [PATCH] Added CI workflows. --- .github/workflows/callable-build.yml | 63 ++++++++++++++++++++++++++++ .github/workflows/on-push-main.yml | 17 ++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/callable-build.yml create mode 100644 .github/workflows/on-push-main.yml diff --git a/.github/workflows/callable-build.yml b/.github/workflows/callable-build.yml new file mode 100644 index 0000000..4606f65 --- /dev/null +++ b/.github/workflows/callable-build.yml @@ -0,0 +1,63 @@ +name: Build Docker Image + +on: + workflow_call: + inputs: + image_tag: + type: string + required: true + ghcr_username: + type: string + required: true + ghcr_image_name: + type: string + required: true + secrets: + ghcr_token: + required: true + +jobs: + build: + name: Build Docker Image + runs-on: ubuntu-latest + + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker Layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ inputs.ghcr_username }} + password: ${{ secrets.ghcr_token }} + + - name: Build & Push Docker Image + id: docker_build + uses: docker/build-push-action@v6 + env: + GHCR_IMAGE: ghcr.io/${{ inputs.ghcr_image_name }} + with: + context: . + push: true + tags: | + ${{ env.GHCR_IMAGE }}:${{ inputs.image_tag }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + platforms: linux/amd64,linux/arm64/v8 + + - name: Image Digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/on-push-main.yml b/.github/workflows/on-push-main.yml new file mode 100644 index 0000000..0e630d9 --- /dev/null +++ b/.github/workflows/on-push-main.yml @@ -0,0 +1,17 @@ +name: On Push (Main) + +on: + push: + branches: + - main + +jobs: + build: + name: Build Docker Image + uses: ./.github/workflows/callable-build.yml + with: + ghcr_username: ${{ github.actor }} + ghcr_image_name: ${{ github.repository }} + image_tag: latest + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }}