diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d28ef3..a611ff1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,29 +22,31 @@ jobs: uses: actions/checkout@v4 - name: Log in to Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin + + - name: Build Docker image + run: | + IMAGE_TAG="${{ inputs.tag }}" + BRANCH_SHA_TAG="${{ github.ref_name }}-${{ github.sha }}" + + # Build the image + docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG} . + docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${BRANCH_SHA_TAG} . + + - name: Push Docker image + run: | + IMAGE_TAG="${{ inputs.tag }}" + BRANCH_SHA_TAG="${{ github.ref_name }}-${{ github.sha }}" + + # Push both tags + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG} + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${BRANCH_SHA_TAG} - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=${{ inputs.tag }} - type=sha,prefix={{branch}}- - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Output image tags run: | - echo "Built and pushed image tags: ${{ steps.meta.outputs.tags }}" \ No newline at end of file + IMAGE_TAG="${{ inputs.tag }}" + BRANCH_SHA_TAG="${{ github.ref_name }}-${{ github.sha }}" + echo "Built and pushed image tags:" + echo "- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG}" + echo "- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${BRANCH_SHA_TAG}" \ No newline at end of file