diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index db130613..ada89935 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -4,19 +4,33 @@ on: workflows: [Automated Quality Control] branches: [master] types: [completed] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: - build: + build-and-push-images: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Login to GitHub Packages - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.repository_owner }} --password-stdin - - name: Build latest Docker image - run: docker build -t docker.pkg.github.com/${{ github.repository }}/inferno:latest . - - name: Push latest Docker image - run: docker push docker.pkg.github.com/${{ github.repository }}/inferno:latest - - name: Build SHA Docker image - run: docker build -t docker.pkg.github.com/${{ github.repository }}/inferno:$GITHUB_SHA . - - name: Push SHA Docker image - run: docker push docker.pkg.github.com/${{ github.repository }}/inferno:$GITHUB_SHA + - name: Checkout repository + uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image (With commit hash) + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + labels: ${{ steps.meta.outputs.labels }}