diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml new file mode 100644 index 0000000..14a7503 --- /dev/null +++ b/.github/workflows/build_and_push.yml @@ -0,0 +1,44 @@ +name: Build and push to GHCR + +on: + push: + branches: + - deployment + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Create a SHA tag + id: sha_tag + run: | + tag=$(cut -c 1-7 <<< $GITHUB_SHA) + echo "::set-output name=tag::$tag" + + - name: Checkout code + uses: actions/checkout@v3 + - name: Setup Docker BuildX + uses: docker/setup-buildx-action@v2 + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + push: true + cache-from: type=repository,ref=ghcr.io/python-discord/logviewer:latest + cache-to: type=inline + tags: | + ghcr.io/python-discord/logviewer:latest + ghcr.io/python-discord/logviewer:${{ steps.sha_tag.outputs.tag }}