Skip to content

Commit

Permalink
Merge pull request #5 from buildpacks/jkutner/verify-package
Browse files Browse the repository at this point in the history
Add verify-package image 

Signed-off-by: Ben Hale <bhale@vmware.com>
  • Loading branch information
nebhale committed Nov 5, 2020
2 parents 2413df7 + d15f34d commit b341524
Show file tree
Hide file tree
Showing 7 changed files with 700 additions and 1 deletion.
73 changes: 73 additions & 0 deletions .github/workflows/create-verify-buildpackage-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Create Action verify-buildpackage
"on":
pull_request:
paths:
- verify/**
push:
branches:
- main
paths:
- verify/**
release:
types:
- published
jobs:
create-action:
name: Create Action
runs-on:
- ubuntu-latest
steps:
- if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }}
name: Docker login ghcr.io
uses: docker/login-action@v1
with:
password: ${{ secrets.IMPLEMENTATION_GITHUB_TOKEN }}
registry: ghcr.io
username: ${{ secrets.IMPLEMENTATION_GITHUB_USERNAME }}
- uses: actions/checkout@v2
- id: version
name: Compute Version
run: |
#!/usr/bin/env bash
set -euo pipefail
if [[ ${GITHUB_REF} =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
VERSION=${BASH_REMATCH[1]}
elif [[ ${GITHUB_REF} =~ refs/heads/(.+) ]]; then
VERSION=${BASH_REMATCH[1]}
else
VERSION=$(git rev-parse --short HEAD)
fi
echo "::set-output name=version::${VERSION}"
echo "Selected ${VERSION} from
* ref: ${GITHUB_REF}
* sha: ${GITHUB_SHA}
"
- name: Create Action
run: |
#!/usr/bin/env bash
set -euo pipefail
echo "::group::Building ${TARGET}:${VERSION}"
docker build \
--file Dockerfile \
--build-arg "SOURCE=${SOURCE}" \
--tag "${TARGET}:${VERSION}" \
.
echo "::endgroup::"
if [[ "${PUSH}" == "true" ]]; then
echo "::group::Pushing ${TARGET}:${VERSION}"
docker push "${TARGET}:${VERSION}"
echo "::endgroup::"
else
echo "Skipping push"
fi
env:
PUSH: ${{ github.event_name != 'pull_request' }}
SOURCE: verify/cmd
TARGET: ghcr.io/buildpacks/actions/verify-buildpackage
VERSION: ${{ steps.version.outputs.version }}
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@

[gha]: https://docs.github.com/en/free-pro-team@latest/actions

- [GitHub Actions](#github-actions)
- [Buildpack Info Action](#buildpack-info-action)
- [Inputs](#inputs)
- [Outputs](#outputs)
- [Registry Action](#registry-action)
- [Add](#add)
- [Inputs](#inputs-1)
- [Yank](#yank)
- [Inputs](#inputs-2)
- [Setup pack CLI Action](#setup-pack-cli-action)
- [Inputs](#inputs-3)
- [Verify Buildpackage Action](#verify-buildpackage-action)
- [Inputs](#inputs-4)
- [License](#license)

## Buildpack Info Action
The buildpack-info action parses a `buildpack.toml` and exposes the contents of the `[buildpack]` block as output parameters.

Expand Down Expand Up @@ -84,8 +99,25 @@ uses: buildpacks/github-actions/setup-pack
| `pack-version` | Optional version of [`pack`][pack] to install. Defaults to latest release.
| `yj-version` | Optional version of [`yj`][yj] to install. Defaults to latest release.

## Verify Buildpackage Action
The verify-buildpackage action parses the metadata on a buildpackage and verifies that the `id` and `version` match expected values.

```yaml
uses: docker://ghcr.io/buildpacks/actions/verify-buildpackage
with:
id: test-buildpack
version: "1.0.0"
address: ghcr.io/example/test-buildpack@sha256:04ba2d17480910bd340f0305d846b007148dafd64bc6fc2626870c174b7c7de7
```

#### Inputs
| Parameter | Description
| :-------- | :----------
| `id` | The expected `id` for the buildpackage
| `version` | The expected `version` for the buildpackage
| `address` | The digest-style address of the buildpackage to verify

## License
This library is released under version 2.0 of the [Apache License][a].

[a]: https://www.apache.org/licenses/LICENSE-2.0

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.15

require (
github.com/buildpacks/libcnb v1.18.0
github.com/google/go-containerregistry v0.1.4
github.com/google/go-github/v32 v32.1.0
github.com/onsi/gomega v1.10.3
github.com/pelletier/go-toml v1.8.1
Expand Down
Loading

0 comments on commit b341524

Please sign in to comment.