diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml old mode 100644 new mode 100755 index 9d65a66..42ae9f1 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,8 +11,36 @@ jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - uses: actions/checkout@v4 - - name: Build the Docker image - run: docker build . --file backend/Dockerfile --tag splashflag:$(date +%s) + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha,prefix={{branch}}- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: backend/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/backend/Dockerfile b/backend/Dockerfile old mode 100644 new mode 100755