Skip to content

Commit from GitHub Actions (ci) #34

Commit from GitHub Actions (ci)

Commit from GitHub Actions (ci) #34

Workflow file for this run

name: ci
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
proto_ref:
proto_sha:
push:
branches:
- main
- v*
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for PRs
pull_request:
env:
VAULT_ADDR: https://vault.eng.aserto.com/
GO_VERSION: "1.17"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Read Configuration
uses: hashicorp/[email protected]
id: vault
with:
url: ${{ env.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/github "SSH_PRIVATE_KEY" | SSH_PRIVATE_KEY;
kv/data/github "READ_WRITE_TOKEN" | READ_WRITE_TOKEN;
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Install dependencies
run: |
mkdir -p $HOME/.ssh
umask 0077 && echo -e "${SSH_PRIVATE_KEY}" > $HOME/.ssh/id_rsa
ssh-keyscan github.com >> $HOME/.ssh/known_hosts
git config --global url."[email protected]:".insteadOf https://github.com/
git config --global user.email "[email protected]"
git config --global user.name "Aserto Bot"
eval `ssh-agent`
ssh-add $HOME/.ssh/id_rsa
go run mage.go deps
- name: Clean generated code
run: go run mage.go clean
- name: Generate
run: go run mage.go generate
- name: Commit changes
id: commit_changes
if: github.event_name == 'workflow_dispatch'
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
- name: Dispatch to aserto-dev/ts-authorizer if a change was committed
if: steps.commit_changes.outputs.committed && github.event_name == 'workflow_dispatch'
uses: benc-uk/workflow-dispatch@v1
with:
inputs: '{"OPENAPI_SHA": "${{ steps.commit_changes.outputs.commit_sha }}", "PROTO_REF": "${{ github.event.inputs.proto_ref }}"}'
ref: main
repo: aserto-dev/ts-authorizer
token: ${{ steps.vault.outputs.READ_WRITE_TOKEN }}
workflow: generate
release:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Read Configuration
uses: hashicorp/[email protected]
id: vault
with:
url: ${{ env.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/readme "README_VERSION_API_KEY" | README_VERSION_API_KEY;
kv/data/readme "AUTHORIZER_API_DEFINITION_ID" | AUTHORIZER_API_DEFINITION_ID;
- name: Checkout
uses: actions/checkout@v2
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Update API spec version
id: latest_readmeio_version
shell: bash
run: |
echo "Install rdme"
npm install [email protected]
echo "Npm fund"
npm fund
echo "Get versions"
LATEST_READMEIO_VERSION=$(curl -X GET \
https://dash.readme.io/api/v1/version \
-u ${{ steps.vault.outputs.README_VERSION_API_KEY }}:)
echo "Compute latest versions"
LATEST_READMEIO_VERSION=$(echo "$LATEST_READMEIO_VERSION" | jq -r 'sort_by(.createdAt)[-1].version')
echo "$LATEST_READMEIO_VERSION"
echo "Publish authorizer API spec"
npx rdme openapi ./publish/authorizer/openapi.json --key ${{ steps.vault.outputs.README_VERSION_API_KEY }} --id ${{ steps.vault.outputs.AUTHORIZER_API_DEFINITION_ID }}
echo "Update API spec version"
npx rdme versions:update --version=$LATEST_READMEIO_VERSION --key ${{ steps.vault.outputs.README_VERSION_API_KEY }} --isPublic true --main true --beta false <<< ${{ env.RELEASE_VERSION }}