build(deps): bump docker/login-action from 3 to 4 #66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "v*.*.*" | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| flavor: | | |
| latest=false | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=sha,format=short | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref_type == 'tag' }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Make package public | |
| run: | | |
| PACKAGE_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| PACKAGE_NAME_ENCODED="${PACKAGE_NAME//\//%2F}" | |
| # Try user endpoint first (for personal repos) | |
| RESPONSE=$(curl -s -w "\n%{http_code}" -X PUT \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/user/packages/container/${PACKAGE_NAME_ENCODED}/visibility" \ | |
| -d '{"visibility":"public"}') | |
| HTTP_CODE=$(echo "$RESPONSE" | tail -n1) | |
| # If user endpoint fails, try org endpoint | |
| if [ "$HTTP_CODE" != "204" ] && [ "$HTTP_CODE" != "200" ]; then | |
| OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') | |
| curl -s -w "\n%{http_code}" -X PUT \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/orgs/${OWNER}/packages/container/${PACKAGE_NAME_ENCODED}/visibility" \ | |
| -d '{"visibility":"public"}' || echo "Note: Package visibility may need to be set manually at https://github.com/${{ github.repository }}/pkgs/container/document/settings" | |
| else | |
| echo "✅ Package set to public" | |
| fi |