2022-07-15 04:23:52 -04:00
|
|
|
name: Publish CLI reference to documentation
|
|
|
|
on:
|
2022-10-12 04:50:06 -04:00
|
|
|
workflow_dispatch:
|
2022-07-15 04:23:52 -04:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2022-09-03 11:47:47 -04:00
|
|
|
paths:
|
2022-09-09 04:26:25 -04:00
|
|
|
- "cli/cmd/**"
|
|
|
|
- "cli/internal/cmd/**"
|
2022-09-16 09:46:23 -04:00
|
|
|
- "hack/clidocgen/**"
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
publish-to-docs:
|
2022-11-10 10:55:24 -05:00
|
|
|
runs-on: ubuntu-22.04
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout Constellation
|
2023-01-05 10:17:51 -05:00
|
|
|
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-10 11:22:26 -05:00
|
|
|
with:
|
2022-12-19 09:21:28 -05:00
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
2022-07-15 04:23:52 -04:00
|
|
|
|
2022-09-14 09:14:26 -04:00
|
|
|
- name: Setup Go environment
|
2022-12-14 08:55:14 -05:00
|
|
|
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
|
2022-07-15 04:23:52 -04:00
|
|
|
with:
|
2022-12-07 08:27:43 -05:00
|
|
|
go-version: "1.19.4"
|
2022-09-14 09:14:26 -04:00
|
|
|
cache: true
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
- name: Generate reference docs
|
2022-09-09 05:19:28 -04:00
|
|
|
run: go run . | cat header.md - > ../../cli.md
|
|
|
|
working-directory: hack/clidocgen
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
- name: Get commit sha
|
|
|
|
run: |
|
2022-11-11 08:49:16 -05:00
|
|
|
echo "COMMIT_END=$(echo ${{ github.sha }} | cut -c1-8)" >> "$GITHUB_ENV"
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
- name: Check if action branch exists
|
|
|
|
run: |
|
2022-11-11 08:49:16 -05:00
|
|
|
ex="$(git ls-remote --heads origin action/constellation/update-cli-reference)"
|
2022-12-09 05:51:38 -05:00
|
|
|
echo "EXISTS=$(if [[ -z "$ex" ]]; then echo 0; else echo 1; fi)" >> "$GITHUB_ENV"
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
- name: Publish new reference (create new branch)
|
|
|
|
if: ${{ env.EXISTS == 0 }}
|
2022-10-12 12:05:58 -04:00
|
|
|
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37 # tag=v1.1.1
|
2022-07-15 04:23:52 -04:00
|
|
|
env:
|
|
|
|
API_TOKEN_GITHUB: ${{ secrets.CI_GITHUB_REPOSITORY }}
|
|
|
|
with:
|
2022-09-09 04:26:25 -04:00
|
|
|
source_file: "cli.md"
|
|
|
|
destination_repo: "edgelesssys/constellation"
|
|
|
|
destination_branch_create: "action/constellation/update-cli-reference"
|
|
|
|
destination_folder: "docs/docs/reference"
|
|
|
|
user_name: "${{ github.actor }}"
|
|
|
|
user_email: "${{ github.actor }}@users.noreply.github.com"
|
|
|
|
commit_message: "CLI reference was updated by edgelesssys/constellation@${{ env.COMMIT_END}}"
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
- name: Publish new reference (update branch)
|
|
|
|
if: ${{ env.EXISTS == 1 }}
|
2022-10-12 12:05:58 -04:00
|
|
|
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37 # tag=v1.1.1
|
2022-07-15 04:23:52 -04:00
|
|
|
env:
|
|
|
|
API_TOKEN_GITHUB: ${{ secrets.CI_GITHUB_REPOSITORY }}
|
|
|
|
with:
|
2022-09-09 04:26:25 -04:00
|
|
|
source_file: "cli.md"
|
|
|
|
destination_repo: "edgelesssys/constellation"
|
|
|
|
destination_branch: "action/constellation/update-cli-reference"
|
|
|
|
destination_folder: "docs/docs/reference"
|
|
|
|
user_name: "${{ github.actor }}"
|
|
|
|
user_email: "${{ github.actor }}@users.noreply.github.com"
|
|
|
|
commit_message: "CLI reference was updated by edgelesssys/constellation@${{ env.COMMIT_END}}"
|