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: Build silta cli binary on release creation | |
on: | |
release: | |
types: [created] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
tests-matrix: | |
name: Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux, darwin, windows] | |
goarch: [amd64, arm64] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: azure/setup-helm@v3 | |
with: | |
version: 'v3.6.3' | |
name: Install Helm | |
- name: Add wunderio Helm repo | |
run: helm repo add wunderio https://storage.googleapis.com/charts.wdr.io | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19.1 | |
- name: Run tests | |
run: go test -v ./tests | |
releases-matrix: | |
name: Cross compile and release Go Binaries | |
runs-on: ubuntu-latest | |
needs: tests-matrix | |
strategy: | |
matrix: | |
goos: [linux, windows] | |
goarch: [amd64, arm64] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set output | |
id: vars | |
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
- uses: wangyoucao577/go-release-action@v1.24 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
goos: ${{ matrix.goos }} | |
goarch: ${{ matrix.goarch }} | |
goversion: "https://go.dev/dl/go1.19.1.linux-amd64.tar.gz" | |
binary_name: "silta" | |
ldflags: "-X github.com/wunderio/silta-cli/internal/common.Version=${{ steps.vars.outputs.tag }} -s -w" | |
circleci-k8s-test-build: | |
name: Test released CLI | |
runs-on: ubuntu-latest | |
needs: releases-matrix | |
strategy: | |
matrix: | |
project: [ | |
{org: "wunderio", repo: "drupal-project-k8s", branch: "master"}, | |
{org: "wunderio", repo: "frontend-project-k8s", branch: "master"}, | |
{org: "wunderio", repo: "simple-project-k8s", branch: "master"} | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Validate released cli with ${{ matrix.project.REPO_NAME }} | |
run: | | |
REPO_NAME="${{ matrix.project.repo }}" | |
ORG_NAME="${{ matrix.project.org }}" | |
BRANCH_NAME="${{ matrix.project.branch }}" | |
CIRCLECI_DEV_API_TOKEN_B64=$(echo -n "${{ secrets.CIRCLECI_DEV_API_TOKEN }}:" | base64) | |
if [ -z "${{ secrets.CIRCLECI_DEV_API_TOKEN }}" ]; then | |
echo "Repository secrets is missing CIRCLECI_DEV_API_TOKEN variable." | |
exit 1 | |
fi | |
echo "Running ${ORG_NAME}/${REPO_NAME}/${BRANCH_NAME} build on CircleCI" | |
echo "Project link: https://app.circleci.com/pipelines/github/${ORG_NAME}/${REPO_NAME}?branch=${BRANCH_NAME}" | |
# Trigger a new pipeline | |
PIPELINE_ID=$(curl --request POST \ | |
--url "https://circleci.com/api/v2/project/gh/wunderio/${REPO_NAME}/pipeline" \ | |
--header "content-type: application/json" \ | |
--data "{\"branch\":\"${BRANCH_NAME}\"}" \ | |
--header "authorization: Basic ${CIRCLECI_DEV_API_TOKEN_B64}" --silent | jq -r '.id') | |
echo "Pipeline ID: ${PIPELINE_ID}" | |
sleep 10 | |
# Wait for pipeline to be complete | |
while true; do | |
PIPELINE_STATUS=$(curl --request GET \ | |
--url "https://circleci.com/api/v2/pipeline/${PIPELINE_ID}/workflow" \ | |
--header "authorization: Basic ${CIRCLECI_DEV_API_TOKEN_B64}" --silent | jq -r '.items[0].status') | |
if [ "${PIPELINE_STATUS}" = "success" ]; then | |
echo "Pipeline completed successfully" | |
break | |
elif [ "${PIPELINE_STATUS}" != "created" ] && [ "${PIPELINE_STATUS}" != "running" ]; then | |
echo "Pipeline status: ${PIPELINE_STATUS}, failing the test" | |
exit 1 | |
fi | |
echo "current status: ${PIPELINE_STATUS}" | |
sleep 10 | |
done |