v0.0.18 #4
Workflow file for this run
This file contains 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 | |
jobs: | |
push: | |
name: Push | |
runs-on: ubuntu-latest | |
steps: | |
- 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 "::set-output name=tag_full::${FULL_VERSION}" | |
echo "::set-output name=tag_minor::${MINOR_VERSION}" | |
echo "::set-output name=tag_major::${MAJOR_VERSION}" | |
echo "::set-output name=download_url::$(jq -r '.release.assets[] | select(.name | endswith(".cnb")) | .url' "${GITHUB_EVENT_PATH}")" | |
- name: Download | |
id: download | |
uses: paketo-buildpacks/github-config/actions/release/download-asset@main | |
with: | |
url: ${{ steps.event.outputs.download_url }} | |
output: "/github/workspace/buildpackage.cnb" | |
token: ${{ secrets.MS_BOT_GITHUB_TOKEN }} | |
- name: Validate version | |
run: | | |
buidpackTomlVersion=$(sudo skopeo inspect "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" | jq -r '.Labels."io.buildpacks.buildpackage.metadata" | fromjson | .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: Push to DockerHub | |
id: push | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} | |
REGISTRY_OWNER: anyninesgmbh | |
run: | | |
REPOSITORY="${REGISTRY_OWNER}/${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}" # translates '_github_username_/buildpack' to 'anyninesgmbh/buildpack' for storing in docker.io registry | |
IMAGE="index.docker.io/${REPOSITORY}" | |
echo "${DOCKERHUB_PASSWORD}" | sudo skopeo login --username "${DOCKERHUB_USERNAME}" --password-stdin index.docker.io | |
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:${{ steps.event.outputs.tag_full }}" | |
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:${{ steps.event.outputs.tag_minor }}" | |
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:${{ steps.event.outputs.tag_major }}" | |
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://${IMAGE}:latest" | |
echo "::set-output name=image::${IMAGE}" | |
echo "::set-output name=digest::$(sudo skopeo inspect "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" | jq -r .Digest)" | |
- 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: ${{ steps.push.outputs.image }}@${{ steps.push.outputs.digest }} | |
token: ${{ secrets.MS_BOT_GITHUB_TOKEN }} |