2022-07-15 04:23:52 -04:00
|
|
|
name: Publish CLI reference to documentation
|
|
|
|
on:
|
|
|
|
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-08-17 10:58:36 -04:00
|
|
|
workflow_dispatch:
|
2022-07-15 04:23:52 -04:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
publish-to-docs:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout Constellation
|
2022-07-20 04:48:01 -04:00
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
|
2022-07-15 04:23:52 -04:00
|
|
|
with:
|
|
|
|
path: constellation
|
|
|
|
|
|
|
|
- name: Checkout docs
|
2022-07-20 04:48:01 -04:00
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
|
2022-07-15 04:23:52 -04:00
|
|
|
with:
|
|
|
|
repository: edgelesssys/constellation-docs
|
|
|
|
token: ${{ secrets.CI_GITHUB_REPOSITORY }}
|
|
|
|
path: docs
|
|
|
|
|
|
|
|
- name: Set up Go
|
2022-08-24 05:59:35 -04:00
|
|
|
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f
|
2022-07-15 04:23:52 -04:00
|
|
|
with:
|
|
|
|
go-version: 1.18
|
|
|
|
|
|
|
|
- name: Generate reference docs
|
|
|
|
run: |
|
|
|
|
cd constellation/hack/clidocgen
|
|
|
|
go build .
|
|
|
|
./clidocgen > content.md
|
|
|
|
cat header.md content.md > ../../../cli.md
|
|
|
|
|
|
|
|
- name: Get commit sha
|
|
|
|
run: |
|
|
|
|
echo "COMMIT_END=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Check if action branch exists
|
|
|
|
run: |
|
|
|
|
ex=$(git --git-dir=./docs/.git ls-remote --heads origin action/constellation/update-cli-reference)
|
|
|
|
echo "EXISTS=$(if [ -z "$ex" ]; then echo 0; else echo 1; fi)" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Publish new reference (create new branch)
|
|
|
|
if: ${{ env.EXISTS == 0 }}
|
2022-07-20 04:48:01 -04:00
|
|
|
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37
|
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-07-20 04:48:01 -04:00
|
|
|
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37
|
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}}"
|