Skip to content

Commit

Permalink
Update CI and tooling (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Aug 22, 2024
1 parent f99e415 commit 51f2a5c
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 116 deletions.
45 changes: 39 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,55 @@ on:
- "master"

jobs:
setup:
runs-on: ubuntu-latest
outputs:
releases: ${{ steps.releases.outputs.releases }}
steps:
- id: releases
run: |
echo "releases=$(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{github.repository}}/releases?per_page=100" | jq -c '[.[].tag_name]')" >> $GITHUB_OUTPUT
releases:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
release: ${{fromJson(needs.setup.outputs.releases)}}
steps:
- uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
version: "tags/${{ matrix.release }}"
file: "keymanager-oapi.json"
target: "deploy/releases/${{ matrix.release }}/keymanager-oapi.json"
- name: Save releases (artifact)
uses: actions/upload-artifact@v3
with:
name: releases
retention-days: 7
path: |
deploy/releases
deploy:
needs: releases
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm i -g @apidevtools/swagger-cli@4
- name: Prepare deploy directory
run: |
mkdir ./deploy
cp -r dist ./deploy
cp -r assets ./deploy
cp -r index.html ./deploy
- name: Bundle spec
uses: mpetrunic/swagger-cli-action@v1.0.0
cp index.html ./deploy
- name: Restore releases
uses: actions/download-artifact@v3
with:
command: "bundle ./keymanager-oapi.yaml -r -t yaml -o ./deploy/keymanager-oapi.yaml"
name: releases
path: deploy/releases
- name: Bundle spec
run: "swagger-cli bundle ./keymanager-oapi.yaml -r -t yaml -o ./deploy/keymanager-oapi.yaml"
- name: Publish to Github Pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./deploy
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- "master"
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm i -g @apidevtools/swagger-cli@4 @redocly/cli@1.19.0

- name: Lint spec
uses: vaibhav-jain/spectral-action/@v2.6.1
with:
file_path: keymanager-oapi.yaml
run: redocly lint ./keymanager-oapi.yaml

- name: Bundle spec
uses: mpetrunic/swagger-cli-action@v1.0.0
with:
command: "bundle ./keymanager-oapi.yaml -r -t yaml -o ./bundle.yaml"
run: "swagger-cli bundle ./keymanager-oapi.yaml -r -t yaml -o ./deploy/keymanager-oapi.yaml"
45 changes: 45 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Pre-release

on:
push:
tags:
- "v*-alpha.*"
- "v*-beta.*"
- "v*-rc.*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm i -g @apidevtools/swagger-cli@4
- name: Update Spec version
run: "sed -i 's/version: \"Dev/version: \"${{ github.ref_name }}/' ./keymanager-oapi.yaml"
- name: Bundle yaml spec
run: "swagger-cli bundle ./keymanager-oapi.yaml -r -t yaml -o ./deploy/keymanager-oapi.yaml"
- name: Bundle json spec
run: "swagger-cli bundle ./keymanager-oapi.yaml -r -t json -o ./deploy/keymanager-oapi.json"
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
draft: false
prerelease: true
files: |
./deploy/keymanager-oapi.yaml
./deploy/keymanager-oapi.json
fail_on_unmatched_files: true
- name: Rollback Release
if: failure()
uses: author/action-rollback@1.0.4
with:
release_id: ${{ steps.create_release.outputs.id }}
tag: ${{ github.ref }}
delete_orphan_tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 changes: 33 additions & 34 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,56 @@ on:
push:
tags:
- "v*"
- "!v*-alpha.*"
- "!v*-beta.*"
- "!v*-rc.*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm i -g @apidevtools/swagger-cli@4
- name: Update Spec version
run: "sed -i 's/version: \"Dev/version: \"${{ github.ref_name }}/' ./keymanager-oapi.yaml"
- name: Bundle yaml spec
uses: mpetrunic/swagger-cli-action@v1.0.0
with:
command: "bundle ./keymanager-oapi.yaml -r -t yaml -o ./deploy/keymanager-oapi.yaml"
run: "swagger-cli bundle ./keymanager-oapi.yaml -r -t yaml -o ./deploy/keymanager-oapi.yaml"
- name: Bundle json spec
uses: mpetrunic/swagger-cli-action@v1.0.0
run: "swagger-cli bundle ./keymanager-oapi.yaml -r -t json -o ./deploy/keymanager-oapi.json"
- name: Update index.html
run: |
sed -i "/urls:/a \ {url: \"./releases/${{ github.ref_name }}/keymanager-oapi.json\", name: \"${{ github.ref_name }}\"}," ./index.html
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
command: "bundle ./keymanager-oapi.yaml -r -t json -o ./deploy/keymanager-oapi.json"
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Release ${{ github.ref_name }}"
branch: release-${{ github.ref_name }}
title: "Release ${{ github.ref_name }}"
body: ""
base: master
add-paths: index.html
- name: Create Release
id: create_release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Yaml Bundle
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./deploy/keymanager-oapi.yaml
asset_name: keymanager-oapi.yaml
asset_content_type: text/x-yaml
- name: Upload Json Bundle
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./deploy/keymanager-oapi.json
asset_name: keymanager-oapi.json
asset_content_type: application/json
files: |
./deploy/keymanager-oapi.yaml
./deploy/keymanager-oapi.json
fail_on_unmatched_files: true
- name: Rollback Release
if: failure()
uses: author/action-rollback@stable
uses: author/action-rollback@1.0.4
with:
# Using a known release ID
id: ${{ steps.create_release.id }}
# Using a tag name
release_id: ${{ steps.create_release.outputs.id }}
tag: ${{ github.ref }}
# Always delete} the tag, even if a release is not associated with it.
always_delete_tag: true
delete_orphan_tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Spellcheck

on:
push:
branches:
- "master"
pull_request:
workflow_dispatch:

jobs:
build:
name: Spellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rojopolis/spellcheck-github-actions@0.40.0
name: Spellcheck
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
.DS_Store
.DS_Store
deploy
node_modules
7 changes: 7 additions & 0 deletions .redocly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends:
- recommended
rules:
no-unused-components: error
operation-4xx-response: off
operation-tag-defined: error
security-defined: off
41 changes: 0 additions & 41 deletions .spectral.yml

This file was deleted.

Loading

0 comments on commit 51f2a5c

Please sign in to comment.