v3.2.0 #160
Workflow file for this run
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: Push Buildpackage | |
| on: | |
| release: | |
| types: | |
| - published | |
| env: | |
| REGISTRIES_FILENAME: "registries.json" | |
| GCR_REGISTRY: "gcr.io" | |
| GCR_PASSWORD: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }} | |
| GCR_USERNAME: "_json_key" | |
| DOCKERHUB_REGISTRY: docker.io | |
| DOCKERHUB_USERNAME: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} | |
| DOCKERHUB_PASSWORD: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }} | |
| jobs: | |
| push: | |
| name: Push | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Parse Event | |
| id: event | |
| run: | | |
| FULL_VERSION="$(jq -r '.release.tag_name' "${GITHUB_EVENT_PATH}" | sed s/^v//)" | |
| MINOR_VERSION="$(echo "${FULL_VERSION}" | awk -F '.' '{print $1 "." $2 }')" | |
| MAJOR_VERSION="$(echo "${FULL_VERSION}" | awk -F '.' '{print $1 }')" | |
| echo "tag_full=${FULL_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag_minor=${MINOR_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag_major=${MAJOR_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "download_tgz_file_url=$(jq -r '.release.assets[] | select(.name | endswith(".tgz")) | .url' "${GITHUB_EVENT_PATH}")" >> "$GITHUB_OUTPUT" | |
| - name: Download .tgz buildpack release artifact | |
| uses: paketo-buildpacks/github-config/actions/release/download-asset@main | |
| with: | |
| url: ${{ steps.event.outputs.download_tgz_file_url }} | |
| output: "/github/workspace/buildpack-release-artifact.tgz" | |
| token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | |
| - name: Parse Configs | |
| id: parse_configs | |
| run: | | |
| registries_filename="${{ env.REGISTRIES_FILENAME }}" | |
| push_to_dockerhub=true | |
| push_to_gcr=false | |
| if [[ -f $registries_filename ]]; then | |
| if jq 'has("dockerhub")' $registries_filename > /dev/null; then | |
| push_to_dockerhub=$(jq '.dockerhub' $registries_filename) | |
| fi | |
| if jq 'has("GCR")' $registries_filename > /dev/null; then | |
| push_to_gcr=$(jq '.GCR' $registries_filename) | |
| fi | |
| fi | |
| echo "push_to_dockerhub=${push_to_dockerhub}" >> "$GITHUB_OUTPUT" | |
| echo "push_to_gcr=${push_to_gcr}" >> "$GITHUB_OUTPUT" | |
| - name: Install yj and crane | |
| uses: buildpacks/github-actions/[email protected] | |
| - name: Validate version | |
| run: | | |
| buidpackTomlVersion=$(tar -xzf buildpack-release-artifact.tgz --to-stdout buildpack.toml | yj -tj | jq -r .buildpack.version) | |
| githubReleaseVersion="${{ steps.event.outputs.tag_full }}" | |
| if [[ "$buidpackTomlVersion" != "$githubReleaseVersion" ]]; then | |
| echo "Version in buildpack.toml ($buidpackTomlVersion) and github release ($githubReleaseVersion) are not identical" | |
| exit 1 | |
| fi | |
| - name: Docker login docker.io | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.DOCKERHUB_USERNAME }} | |
| password: ${{ env.DOCKERHUB_PASSWORD }} | |
| registry: ${{ env.DOCKERHUB_REGISTRY }} | |
| - name: Docker login gcr.io | |
| uses: docker/login-action@v3 | |
| if: ${{ steps.parse_configs.outputs.push_to_gcr == 'true' }} | |
| with: | |
| username: ${{ env.GCR_USERNAME }} | |
| password: ${{ env.GCR_PASSWORD }} | |
| registry: ${{ env.GCR_REGISTRY }} | |
| - name: Push to GCR | |
| if: ${{ steps.parse_configs.outputs.push_to_gcr == 'true' }} | |
| run: | | |
| ./scripts/publish.sh \ | |
| --archive-path buildpack-release-artifact.tgz \ | |
| --image-ref "gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_full }}" | |
| crane copy "gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_full }}" "gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_minor }}" | |
| crane copy "gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_full }}" "gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_major }}" | |
| crane copy "gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_full }}" "gcr.io/${{ github.repository }}:latest" | |
| - name: Push to DockerHub | |
| if: ${{ steps.parse_configs.outputs.push_to_dockerhub == 'true' }} | |
| id: push | |
| run: | | |
| IMAGE="${GITHUB_REPOSITORY_OWNER/-/}/${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}" # translates 'paketo-buildpacks/bundle-install' to 'paketobuildpacks/bundle-install' | |
| ./scripts/publish.sh \ | |
| --archive-path buildpack-release-artifact.tgz \ | |
| --image-ref "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" | |
| pushed_image_index_digest=$(crane digest "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" | xargs) | |
| crane copy "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_minor }}" | |
| crane copy "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_major }}" | |
| crane copy "${DOCKERHUB_REGISTRY}/${IMAGE}:${{ steps.event.outputs.tag_full }}" "${DOCKERHUB_REGISTRY}/${IMAGE}:latest" | |
| echo "image=${IMAGE}" >> "$GITHUB_OUTPUT" | |
| echo "digest=$pushed_image_index_digest" >> "$GITHUB_OUTPUT" | |
| - name: Register with CNB Registry | |
| uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:main | |
| with: | |
| id: ${{ github.repository }} | |
| version: ${{ steps.event.outputs.tag_full }} | |
| address: index.docker.io/${{ steps.push.outputs.image }}@${{ steps.push.outputs.digest }} | |
| token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | |
| failure: | |
| name: Alert on Failure | |
| runs-on: ubuntu-24.04 | |
| needs: [push] | |
| if: ${{ always() && needs.push.result == 'failure' }} | |
| steps: | |
| - name: File Failure Alert Issue | |
| uses: paketo-buildpacks/github-config/actions/issue/file@main | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| repo: ${{ github.repository }} | |
| label: "failure:push" | |
| comment_if_exists: true | |
| issue_title: "Failure: Push Buildpackage workflow" | |
| issue_body: | | |
| Push Buildpackage workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). | |
| comment_body: | | |
| Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} |