From 0a298d6a698cb293534c062c59c749e3da848fe1 Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Wed, 25 Sep 2024 23:14:15 +0530 Subject: [PATCH 1/6] Automate AMC command reference documentation --- .../workflows/generate-command-reference.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/generate-command-reference.yml diff --git a/.github/workflows/generate-command-reference.yml b/.github/workflows/generate-command-reference.yml new file mode 100644 index 00000000..d2493b7c --- /dev/null +++ b/.github/workflows/generate-command-reference.yml @@ -0,0 +1,24 @@ +name: Automatically generate command reference topics +on: + push: + workflow_dispatch: + +jobs: + run-tests: + runs-on: ubuntu-24.04 + steps: + - name: Setup Anbox Cloud + uses: canonical/anbox-cloud-github-action@main + with: + ubuntu-pro-token: ${{ secrets.UBUNTU_PRO_TOKEN }} + - name: Checkout repo + uses: actions/checkout@v4 + - name: Generate AMC command reference documentation + run: amc generate documentation -f markdown -d ./reference/cmd-ref/amc-command-reference + - name: Commit changes + if: ${{ github.ref == 'refs/heads/main' }} + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: 'Generate AMC command reference documentation' + add: './reference/cmd-ref/amc-command-reference' From 276cf85fff2cef7d5107f235fe6088c081f0ddf6 Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Fri, 27 Sep 2024 08:15:04 +0530 Subject: [PATCH 2/6] Generate files in a new directory --- .../workflows/generate-command-reference.yml | 39 +++++++++++++++---- reference/cmd-ref/amc/.keep | 0 reference/cmd-ref/appliance/.keep | 0 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 reference/cmd-ref/amc/.keep create mode 100644 reference/cmd-ref/appliance/.keep diff --git a/.github/workflows/generate-command-reference.yml b/.github/workflows/generate-command-reference.yml index d2493b7c..9b93690a 100644 --- a/.github/workflows/generate-command-reference.yml +++ b/.github/workflows/generate-command-reference.yml @@ -3,22 +3,47 @@ on: push: workflow_dispatch: +env: + AMC_COMMAND_REFERENCE_DIR: "./reference/cmd-ref/amc" + APPLIANCE_COMMAND_REFERENCE_DIR: "./reference/cmd-ref/appliance" + jobs: run-tests: runs-on: ubuntu-24.04 steps: + - name: Determine base version + id: base_version + run: | + echo "value=$(cat .base_version)" >> "$GITHUB_OUTPUT" - name: Setup Anbox Cloud - uses: canonical/anbox-cloud-github-action@main + uses: canonical/anbox-cloud-github-action@39490d442cc0921fe614f7044b9f3dc8bd89725c with: - ubuntu-pro-token: ${{ secrets.UBUNTU_PRO_TOKEN }} + channel: ${{ steps.base_version.outputs.value }}/stable - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - name: Delete existing files - amc reference + run: rm -rf $AMC_COMMAND_REFERENCE_DIR/* - name: Generate AMC command reference documentation - run: amc generate documentation -f markdown -d ./reference/cmd-ref/amc-command-reference + run: amc generate documentation -f markdown -d $AMC_COMMAND_REFERENCE_DIR + - name: Set $AMC_COMMAND_REFERENCE_DIR as an output + run: echo "value=$AMC_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" + id: amc_command_reference_dir - name: Commit changes - if: ${{ github.ref == 'refs/heads/main' }} - uses: EndBug/add-and-commit@v9 + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions message: 'Generate AMC command reference documentation' - add: './reference/cmd-ref/amc-command-reference' + add: ${{ steps.amc_command_reference_dir.outputs.value }} + - name: Delete existing files - appliance reference + run: rm -rf $APPLIANCE_COMMAND_REFERENCE_DIR/* + - name: Generate appliance command reference documentation + run: sudo anbox-cloud-appliance generate documentation -f markdown -d $APPLIANCE_COMMAND_REFERENCE_DIR + - name: Set $APPLIANCE_COMMAND_REFERENCE_DIR as an output + run: echo "value=$APPLIANCE_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" + id: appliance_command_reference_dir + - name: Commit changes + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 + with: + default_author: github_actions + message: 'Generate appliance command reference documentation' + add: ${{ steps.appliance_command_reference_dir.outputs.value }} diff --git a/reference/cmd-ref/amc/.keep b/reference/cmd-ref/amc/.keep new file mode 100644 index 00000000..e69de29b diff --git a/reference/cmd-ref/appliance/.keep b/reference/cmd-ref/appliance/.keep new file mode 100644 index 00000000..e69de29b From dace96c199dc6a775b3d6018cacc9aafaa97fdcd Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Fri, 27 Sep 2024 09:05:07 +0530 Subject: [PATCH 3/6] Clarify job names --- .github/workflows/generate-command-reference.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-command-reference.yml b/.github/workflows/generate-command-reference.yml index 9b93690a..e02e6f5e 100644 --- a/.github/workflows/generate-command-reference.yml +++ b/.github/workflows/generate-command-reference.yml @@ -28,7 +28,7 @@ jobs: - name: Set $AMC_COMMAND_REFERENCE_DIR as an output run: echo "value=$AMC_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" id: amc_command_reference_dir - - name: Commit changes + - name: Commit AMC command reference changes uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions @@ -41,7 +41,7 @@ jobs: - name: Set $APPLIANCE_COMMAND_REFERENCE_DIR as an output run: echo "value=$APPLIANCE_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" id: appliance_command_reference_dir - - name: Commit changes + - name: Commit appliance command reference changes uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions From ec13557cfab831610688c6694209721c8f59b2da Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Mon, 30 Sep 2024 10:55:50 +0530 Subject: [PATCH 4/6] Fix Anbox Cloud appliance docs generation --- .github/workflows/generate-command-reference.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate-command-reference.yml b/.github/workflows/generate-command-reference.yml index e02e6f5e..b9142a9e 100644 --- a/.github/workflows/generate-command-reference.yml +++ b/.github/workflows/generate-command-reference.yml @@ -28,7 +28,7 @@ jobs: - name: Set $AMC_COMMAND_REFERENCE_DIR as an output run: echo "value=$AMC_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" id: amc_command_reference_dir - - name: Commit AMC command reference changes + - name: Commit changes uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions @@ -37,11 +37,15 @@ jobs: - name: Delete existing files - appliance reference run: rm -rf $APPLIANCE_COMMAND_REFERENCE_DIR/* - name: Generate appliance command reference documentation - run: sudo anbox-cloud-appliance generate documentation -f markdown -d $APPLIANCE_COMMAND_REFERENCE_DIR + run: | + SNAP_DOCS_DIR="/var/snap/anbox-cloud-appliance/common/docs" && \ + sudo mkdir -p $SNAP_DOCS_DIR && \ + sudo anbox-cloud-appliance generate documentation -f markdown -d $SNAP_DOCS_DIR && \ + cp -r $SNAP_DOCS_DIR/* $APPLIANCE_COMMAND_REFERENCE_DIR - name: Set $APPLIANCE_COMMAND_REFERENCE_DIR as an output run: echo "value=$APPLIANCE_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" id: appliance_command_reference_dir - - name: Commit appliance command reference changes + - name: Commit changes uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions From b4b16c2fd8174b0ebbf7f51e48151ecf85c1e7f7 Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Mon, 30 Sep 2024 10:59:28 +0530 Subject: [PATCH 5/6] Update workflow to run only on main branch --- .github/workflows/generate-command-reference.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/generate-command-reference.yml b/.github/workflows/generate-command-reference.yml index b9142a9e..ce8b3e03 100644 --- a/.github/workflows/generate-command-reference.yml +++ b/.github/workflows/generate-command-reference.yml @@ -29,6 +29,7 @@ jobs: run: echo "value=$AMC_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" id: amc_command_reference_dir - name: Commit changes + if: ${{ github.ref == 'refs/heads/main' }} uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions @@ -46,6 +47,7 @@ jobs: run: echo "value=$APPLIANCE_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" id: appliance_command_reference_dir - name: Commit changes + if: ${{ github.ref == 'refs/heads/main' }} uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions From 80212c1b2c781f92d7eb4de0f5705514fd34212c Mon Sep 17 00:00:00 2001 From: Keirthana T S Date: Wed, 2 Oct 2024 22:47:49 +0530 Subject: [PATCH 6/6] Address review feedback --- .../workflows/generate-command-reference.yml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/generate-command-reference.yml b/.github/workflows/generate-command-reference.yml index ce8b3e03..eaa924a6 100644 --- a/.github/workflows/generate-command-reference.yml +++ b/.github/workflows/generate-command-reference.yml @@ -21,35 +21,35 @@ jobs: channel: ${{ steps.base_version.outputs.value }}/stable - name: Checkout repo uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - name: Delete existing files - amc reference - run: rm -rf $AMC_COMMAND_REFERENCE_DIR/* + # Remove existing files, generate AMC command reference - name: Generate AMC command reference documentation - run: amc generate documentation -f markdown -d $AMC_COMMAND_REFERENCE_DIR - - name: Set $AMC_COMMAND_REFERENCE_DIR as an output - run: echo "value=$AMC_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" - id: amc_command_reference_dir + run: | + set -e + rm -rf $AMC_COMMAND_REFERENCE_DIR/* + amc generate documentation -f markdown -d $AMC_COMMAND_REFERENCE_DIR - name: Commit changes if: ${{ github.ref == 'refs/heads/main' }} uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions message: 'Generate AMC command reference documentation' - add: ${{ steps.amc_command_reference_dir.outputs.value }} - - name: Delete existing files - appliance reference - run: rm -rf $APPLIANCE_COMMAND_REFERENCE_DIR/* + add: ${{ env.AMC_COMMAND_REFERENCE_DIR }} + # Remove existing files, generate appliance command reference - name: Generate appliance command reference documentation + env: + SNAP_DOCS_DIR: "/var/snap/anbox-cloud-appliance/common/docs" + # For the appliance command, the files have to be generated inside the Snap + # and then copied to the desired directory because of Snap confinement run: | - SNAP_DOCS_DIR="/var/snap/anbox-cloud-appliance/common/docs" && \ - sudo mkdir -p $SNAP_DOCS_DIR && \ - sudo anbox-cloud-appliance generate documentation -f markdown -d $SNAP_DOCS_DIR && \ + set -e + rm -rf $APPLIANCE_COMMAND_REFERENCE_DIR/* + sudo mkdir -p $SNAP_DOCS_DIR + sudo anbox-cloud-appliance generate documentation -f markdown -d $SNAP_DOCS_DIR cp -r $SNAP_DOCS_DIR/* $APPLIANCE_COMMAND_REFERENCE_DIR - - name: Set $APPLIANCE_COMMAND_REFERENCE_DIR as an output - run: echo "value=$APPLIANCE_COMMAND_REFERENCE_DIR" >> "$GITHUB_OUTPUT" - id: appliance_command_reference_dir - name: Commit changes if: ${{ github.ref == 'refs/heads/main' }} uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: default_author: github_actions message: 'Generate appliance command reference documentation' - add: ${{ steps.appliance_command_reference_dir.outputs.value }} + add: ${{ env.APPLIANCE_COMMAND_REFERENCE_DIR }}