From c719d7606576a81a6dd4bdf0ce3142b4a3a19f99 Mon Sep 17 00:00:00 2001 From: Matthew Vincent Date: Thu, 6 Mar 2025 12:23:17 +0300 Subject: [PATCH] github actions to automate building the docker image --- .github/workflows/build-and-push.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/build-and-push.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 0000000..9707c94 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,38 @@ +name: Publish Docker container + +on: + push: + branches: + - main # or the default branch of your repository + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Get short SHA + id: short-sha + run: echo "::set-output name=sha::$(echo $GITHUB_SHA | cut -c1-6)" + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ghcr.io/${{ github.repository }}/resourcespace:latest + ghcr.io/${{ github.repository }}/resourcespace:${{ steps.short-sha.outputs.sha }} \ No newline at end of file