Skip to content

Commit

Permalink
Enable registration/updating in registry.buildpacks.io
Browse files Browse the repository at this point in the history
  • Loading branch information
ybykov-a9s committed Jun 29, 2022
1 parent 8a43cbe commit de4384a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
with:
user: paketo-bot
token: ${{ secrets.MS_BOT_GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
number: ${{ github.event.pull_request.number }}
67 changes: 67 additions & 0 deletions .github/workflows/push-buildpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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 }}
3 changes: 3 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
api = "0.8"

[buildpack]
description = "A buildpack that allows an app developer to supply credentials for GIT repositories which require authentication"
homepage = "https://github.com/anynines/gitcredentials"
id = "anynines/gitcredentials"
keywords = ["git", "credentials"]
name = "GIT credentials"

[metadata]
Expand Down

0 comments on commit de4384a

Please sign in to comment.