Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using openshift-pipelines/setup-tektoncd Action #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Setup [Shipwright][shpGitHubOrg] (`v1`)
# Setup [Shipwright][shpGitHubOrg] (`v2`)

[![Build][useActionBadgeSVG]][useAction]

Expand All @@ -18,16 +18,18 @@ jobs:
name: Shipwright
steps:
# using KinD to provide the Kubernetes instance and kubectl
- uses: helm/[email protected]
- uses: helm/[email protected]
with:
cluster_name: kind
# golang is a required to deploy the build controller and CLI
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: '1.19.x'
# ko is a dependency to deploy the build controller instance
- uses: imjasonh/[email protected]

# setting up Shipwright Build Controller, CLI and a Container Registry
- uses: shipwright-io/setup@v1
- uses: shipwright-io/setup@v2
```

### Inputs
Expand All @@ -38,28 +40,27 @@ Example usage using defaults:
jobs:
use-action:
steps:
- uses: shipwright-io/setup@v1
- uses: shipwright-io/setup@v2
with:
tekton-version: v0.38.3
shipwright-ref: v0.11.0
cli-ref: v0.11.0
kind-cluster-name: kind
setup-registry: true
registry-hostname: registry.registry.svc.cluster.local
patch-etc-hosts: true
tekton_version: latest
feature_flags: '{}'
shipwright_ref: v0.11.0
cli_ref: v0.11.0
setup_registry: true
registry_hostname: registry.registry.svc.cluster.local
patch_etc_hosts: true
```

The inputs are described below:

| Input | Default | Description |
| ------------------- | ------------------------------------- | -------------------------------------------------------------------------- |
| `tekton-version` | `v0.38.3` | [Tekton Pipeline][tektonPipeline] release version |
| `shipwright-ref` | `v0.11.0` | [Shipwright Build Controller][shpBuild] repository tag or SHA |
| `cli-ref` | `v0.11.0` | [Shipwright CLI][shpCLI] repository tag or SHA |
| `kind-cluster-name` | `kind` | KinD cluster name |
| `setup-registry` | `true` | Setup a Container Registry instance (`true` or `false`) |
| `registry-hostname` | `registry.registry.svc.cluster.local` | Container Registry hostname inside KinD |
| `patch-etc-hosts` | `true` | Patch "/etc/hosts" to alias the Container Registry hostname to "127.0.0.1" |
| Input | Default | Description |
|:------|:-------:|:------------|
| `pipeline_version` | `latest` | [Tekton Pipeline][tektonPipeline] release version |
| `shipwright_ref` | `v0.11.0` | [Shipwright Build Controller][shpBuild] repository tag or SHA |
| `cli_ref` | `v0.11.0` | [Shipwright CLI][shpCLI] repository tag or SHA |
| `setup_registry` | `true` | Setup a Container Registry instance (`true` or `false`) |
| `registry_hostname` | `registry.registry.svc.cluster.local` | Container Registry hostname (Kubernetes service) |
| `patch_etc_hosts` | `true` | Patch "/etc/hosts" with Container Registry hostname as "127.0.0.1" |

The Shipwright components [Build Controller][shpBuild] and [CLI][shpCLI] can be deployed using a specific commit SHA or tag.

Expand All @@ -73,16 +74,16 @@ jobs:
steps:
- uses: shipwright-io/setup@v1
with:
shipwright-ref: _ignore
cli-ref: _ignore
shipwright_ref: _ignore
cli_ref: _ignore
```

## Contributing

To run this action locally, you can use [`act`][nektosAct] as the following example:

```bash
act --secret="GITHUB_TOKEN=${GITHUB_TOKEN}"
act --rm --secret="GITHUB_TOKEN=${GITHUB_TOKEN}" --workflows=".github/workflows/use-action.yaml"
```

The `GITHUB_TOKEN` is necessary for checking out the upstream repositories in the action workspace, and for this purpose the token only needs read-only permissions on the [`shipwright-io` organization][shpGitHubOrg]. The token is provided by default during GitHub Action execution inside GitHub.
Expand Down Expand Up @@ -117,4 +118,4 @@ kubectl --namespace=shipwright-build logs --follow shipwright-build-controller-x
[shpGitHubOrg]: https://github.com/shipwright-io/build
[tektonPipeline]: https://github.com/tektoncd/pipeline
[useAction]: https://github.com/shipwright-io/setup/actions/workflows/use-action.yaml
[useActionBadgeSVG]: https://github.com/shipwright-io/setup/actions/workflows/use-action.yaml/badge.svg
[useActionBadgeSVG]: https://github.com/shipwright-io/setup/actions/workflows/use-action.yaml/badge.svg
68 changes: 27 additions & 41 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,63 @@ name: Shipwright Setup (CI)
description: Installs Shipwright Build Controller, CLI and Container Registry
branding:
color: blue
icon: anchor
icon: anchor
inputs:
tekton-version:
pipeline_version:
description: Tekton Pipelines release version
required: false
default: v0.38.3
shipwright-ref:
default: latest
feature_flags:
description: |
JSON payload for the Tekton Pipelines feature-flags, a configmap containing features toggles.
For instance '{ "enable-custom-tasks": "true" }'.
required: false
default: '{}'
shipwright_ref:
description: Shipwright Build Controller repository reference, tag or SHA
required: false
default: v0.11.0
cli-ref:
cli_ref:
description: Shipwright CLI repository reference, tag or SHA
required: false
default: v0.11.0
kind-cluster-name:
description: KinD cluster name, by default "kind"
required: false
default: kind
setup-registry:
setup_registry:
description: When enabled, the action deploys a Container Registry instance
required: true
default: "true"
registry-hostname:
registry_hostname:
description: Container Registry hostname inside KinD
required: true
default: registry.registry.svc.cluster.local
patch-etc-hosts:
patch_etc_hosts:
description: Patch "/etc/hosts" to alias the Container Registry hostname to "127.0.0.1"
required: true
default: "true"
runs:
using: composite
steps:
- uses: openshift-pipelines/setup-tektoncd@v1
with:
pipeline_version: ${{ inputs.pipeline_version }}
feature_flags: ${{ inputs.feature_flags }}
cli_version: latest
setup_registry: ${{ inputs.setup_registry }}
patch_etc_hosts: ${{ inputs.patch_etc_hosts }}

# pre-flight checks, making sure the dependencies needed for the upcoming steps are available
- shell: bash
working-directory: ${{ github.action_path }}
run: ./probe.sh

# deploying the container registry when input flag is set, waiting for the deployment to reach
# ready status before proceeding
- shell: bash
if: ${{ inputs.setup-registry == 'true' }}
working-directory: ${{ github.action_path }}
run: ./install-registry.sh

# deploying tekton pipline controller and dependencies, waiting for it to reach ready status
- shell: bash
env:
TEKTON_VERSION: ${{ inputs.tekton-version }}
working-directory: ${{ github.action_path }}
run: ./install-tekton.sh

# patches the /etc/hosts to include the container registry hostname resolving to 127.0.0.1
- shell: bash
if: ${{ inputs.patch-etc-hosts == 'true' }}
env:
REGISTRY_HOSTNAME: ${{ inputs.registry-hostname }}
working-directory: ${{ github.action_path }}
run: sudo ./patch-etc-hosts.sh

# checking out the build controller project locally to perform the rollout and inspection of the
# controller instance in the cluster
- uses: actions/checkout@v3
with:
repository: shipwright-io/build
ref: ${{ inputs.shipwright-ref }}
ref: ${{ inputs.shipwright_ref }}
path: src/build
if: ${{ inputs.shipwright-ref != '_ignore' }}
if: ${{ inputs.shipwright_ref != '_ignore' }}
- shell: bash
env:
KIND_CLUSTER_NAME: ${{ inputs.kind-cluster-name }}
working-directory: ${{ github.action_path }}
if: ${{ inputs.shipwright-ref != '_ignore' }}
run: ./install-shipwright.sh
Expand All @@ -82,10 +68,10 @@ runs:
- uses: actions/checkout@v3
with:
repository: shipwright-io/cli
ref: ${{ inputs.cli-ref }}
ref: ${{ inputs.cli_hef }}
path: src/cli
if: ${{ inputs.cli-ref != '_ignore' }}
if: ${{ inputs.cli_ref != '_ignore' }}
- shell: bash
working-directory: ${{ github.action_path }}
if: ${{ inputs.cli-ref != '_ignore' }}
if: ${{ inputs.cli_ref != '_ignore' }}
run: ./install-cli.sh
74 changes: 0 additions & 74 deletions install-registry.sh

This file was deleted.

7 changes: 1 addition & 6 deletions install-shipwright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

set -eu -o pipefail

# the install target uses ko to produce a container image out of the go project, ko loads the
# container image directly into KinD (Kubernetes in Docker), however when using an alternative
# cluster name it needs to be declared using KIND_CLUSTER_NAME environment variable
KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-}"

source common.sh

readonly REPO_NAME="build"
Expand All @@ -21,7 +16,7 @@ fi

cd "${CLONE_DIR}" || fail "Directory '${CLONE_DIR}' does not exit!"

echo "# Deploying Shipwright Controller (pwd='${CLONE_DIR}', kind='${KIND_CLUSTER_NAME}')..."
echo "# Deploying Shipwright Controller (pwd='${CLONE_DIR}')..."
make install-controller-kind

echo "# Waiting for Build Controller rollout..."
Expand Down
27 changes: 0 additions & 27 deletions install-tekton.sh

This file was deleted.

16 changes: 0 additions & 16 deletions patch-etc-hosts.sh

This file was deleted.