diff --git a/README.md b/README.md index 4beb1d5..c3ed654 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Setup [Shipwright][shpGitHubOrg] (`v1`) +# Setup [Shipwright][shpGitHubOrg] (`v2`) [![Build][useActionBadgeSVG]][useAction] @@ -18,16 +18,18 @@ jobs: name: Shipwright steps: # using KinD to provide the Kubernetes instance and kubectl - - uses: helm/kind-action@v1.2.0 + - uses: helm/kind-action@v1.5.0 + 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/setup-ko@v0.6 # setting up Shipwright Build Controller, CLI and a Container Registry - - uses: shipwright-io/setup@v1 + - uses: shipwright-io/setup@v2 ``` ### Inputs @@ -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. @@ -73,8 +74,8 @@ jobs: steps: - uses: shipwright-io/setup@v1 with: - shipwright-ref: _ignore - cli-ref: _ignore + shipwright_ref: _ignore + cli_ref: _ignore ``` ## Contributing @@ -82,7 +83,7 @@ jobs: 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. @@ -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 \ No newline at end of file +[useActionBadgeSVG]: https://github.com/shipwright-io/setup/actions/workflows/use-action.yaml/badge.svg diff --git a/action.yaml b/action.yaml index 3e87008..556da3f 100644 --- a/action.yaml +++ b/action.yaml @@ -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 @@ -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 diff --git a/install-registry.sh b/install-registry.sh deleted file mode 100755 index afffdae..0000000 --- a/install-registry.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash -# -# Deploys a Container Registry instance, waits for the deployment reach running status. -# - -set -eu -o pipefail - -source common.sh - -echo "# Deploying a Container Registry on '${REGISTRY_NAMESPACE}' namespace..." -cat <&2 - exit 1 -fi - -readonly TEKTON_HOST="github.com" -readonly TEKTON_HOST_PATH="tektoncd/pipeline/releases/download" - -echo "# Deploying Tekton Pipelines '${TEKTON_VERSION}'" - -kubectl apply -f "https://${TEKTON_HOST}/${TEKTON_HOST_PATH}/${TEKTON_VERSION}/release.yaml" - -echo "# Waiting for Tekton components..." - -rollout_status "${TEKTON_NAMESPACE}" "tekton-pipelines-controller" -rollout_status "${TEKTON_NAMESPACE}" "tekton-pipelines-webhook" diff --git a/patch-etc-hosts.sh b/patch-etc-hosts.sh deleted file mode 100755 index 9bbbc13..0000000 --- a/patch-etc-hosts.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -# -# Patches /etc/hosts to include the registry FQDN resolving to localhost. -# - -set -eu -o pipefail -set -x - -REGISTRY_HOSTNAME=${REGISTRY_HOSTNAME:-registry.registry.svc.cluster.local} -HOSTS_ENTRY="127.0.0.1 ${REGISTRY_HOSTNAME}" - -readonly ETC_HOSTS="/etc/hosts" - -if ! grep -q "${HOSTS_ENTRY}" ${ETC_HOSTS} ; then - echo "${HOSTS_ENTRY}" |tee -a ${ETC_HOSTS} -fi