|
55 | 55 | runner_os: ${{ runner.os }}
|
56 | 56 | cache_version: cache-v1
|
57 | 57 | docker_registry: ghcr.io
|
| 58 | + |
| 59 | + docker-build-and-push: |
| 60 | + #needs: r-build-and-check |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + contents: read |
| 64 | + packages: write |
| 65 | + # This is used to complete the identity challenge |
| 66 | + # with sigstore/fulcio when running outside of PRs. |
| 67 | + id-token: write |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Checkout Repository |
| 71 | + uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: Set Environment Variables |
| 74 | + run: | |
| 75 | + REPO_LOWER="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" |
| 76 | + REGISTRY=ghcr.io |
| 77 | + echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV |
| 78 | + echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV |
| 79 | + echo "REGISTRY=${REGISTRY}" >> $GITHUB_ENV |
| 80 | + echo "IMAGE=${REGISTRY}/${REPO_LOWER}" >> $GITHUB_ENV |
| 81 | +
|
| 82 | + - name: Show environment |
| 83 | + run: | |
| 84 | + env |
| 85 | +
|
| 86 | + # Install the cosign tool except on PR |
| 87 | + # https://github.com/sigstore/cosign-installer |
| 88 | + - name: Install cosign |
| 89 | + if: github.event_name != 'pull_request' |
| 90 | + uses: sigstore/cosign-installer@v3 |
| 91 | + |
| 92 | + - name: Setup Docker buildx |
| 93 | + uses: docker/setup-buildx-action@v3 |
| 94 | + |
| 95 | + # Login against a Docker registry except on PR |
| 96 | + # https://github.com/docker/login-action |
| 97 | + - name: Log into registry ${{ env.REGISTRY }} |
| 98 | + if: github.event_name != 'pull_request' |
| 99 | + uses: docker/login-action@v3 |
| 100 | + with: |
| 101 | + registry: ${{ env.REGISTRY }} |
| 102 | + username: ${{ github.actor }} |
| 103 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 104 | + |
| 105 | + # Extract metadata (tags, labels) for Docker |
| 106 | + # https://github.com/docker/metadata-action |
| 107 | + - name: Extract Docker metadata |
| 108 | + id: meta |
| 109 | + uses: docker/metadata-action@v5 |
| 110 | + with: |
| 111 | + images: ${{ env.IMAGE }} |
| 112 | + |
| 113 | + # Build and push Docker image with Buildx (don't push on PR) |
| 114 | + # https://github.com/docker/build-push-action |
| 115 | + - name: Build and push Docker image |
| 116 | + id: build-and-push |
| 117 | + uses: docker/build-push-action@v5 |
| 118 | + with: |
| 119 | + context: . |
| 120 | + push: ${{ github.event_name != 'pull_request' }} |
| 121 | + tags: | |
| 122 | + ${{ env.IMAGE }}:latest |
| 123 | + ${{ env.IMAGE }}:${{ env.GIT_SHA }} |
0 commit comments