From c67b7c75b3ca2e41dda7e5156a354b73970c7e63 Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sun, 17 Sep 2023 12:18:20 +0200 Subject: [PATCH] Create multiple actions to make Mako easier to use --- .github/actions/execute-command/README.md | 20 +++++++++ .github/actions/execute-command/action.yml | 29 +++++++++++++ .github/actions/setup-mako/README.md | 11 +---- .github/actions/setup-mako/action.yml | 6 +-- README.md | 37 +++++------------ action.yml | 47 ++++++++++++++++++++++ 6 files changed, 112 insertions(+), 38 deletions(-) create mode 100644 .github/actions/execute-command/README.md create mode 100644 .github/actions/execute-command/action.yml create mode 100644 action.yml diff --git a/.github/actions/execute-command/README.md b/.github/actions/execute-command/README.md new file mode 100644 index 0000000..5ea4dc8 --- /dev/null +++ b/.github/actions/execute-command/README.md @@ -0,0 +1,20 @@ +# execute-command + +A small composite action to run the specified Mako subcommand. + +## Usage + +Add the following step to your workflow: + +```yml +- name: Execute Ryujinx-Mako command + uses: Ryujinx/Ryujinx-Mako/.github/actions/execute-command@master + with: + command: "" + args: "" + app_id: ${{ secrets.MAKO_APP_ID }} + private_key: ${{ secrets.MAKO_PRIVATE_KEY }} + installation_id: ${{ secrets.MAKO_INSTALLATION_ID }} +``` + + diff --git a/.github/actions/execute-command/action.yml b/.github/actions/execute-command/action.yml new file mode 100644 index 0000000..d7e3310 --- /dev/null +++ b/.github/actions/execute-command/action.yml @@ -0,0 +1,29 @@ +name: 'Mako command' +description: 'Execute a Mako subcommand' +inputs: + command: + description: 'Subcommand to execute with Mako' + required: true + args: + description: 'Arguments for the specified subcommand' + required: true + default: '' + app_id: + description: 'GitHub App ID' + required: true + private_key: + description: 'Private key for the GitHub App' + required: true + installation_id: + description: 'GitHub App Installation ID' + required: true +runs: + using: 'composite' + steps: + - run: | + poetry -n -C "${{ github.action_path }}../" run ryujinx-mako ${{ inputs.command }} ${{ inputs.args }} + shell: bash + env: + MAKO_APP_ID: ${{ inputs.app_id }} + MAKO_PRIVATE_KEY: ${{ inputs.private_key }} + MAKO_INSTALLATION_ID: ${{ inputs.installation_id }} diff --git a/.github/actions/setup-mako/README.md b/.github/actions/setup-mako/README.md index 2580d4e..2efff3e 100644 --- a/.github/actions/setup-mako/README.md +++ b/.github/actions/setup-mako/README.md @@ -6,18 +6,11 @@ It installs poetry and all module dependencies. ## Usage -Add the following steps to your workflow: +Add the following step to your workflow: ```yml -- name: Checkout Ryujinx-Mako - uses: actions/checkout@v3 - with: - repository: Ryujinx/Ryujinx-Mako - ref: master - path: ".ryujinx-mako" - - name: Setup Ryujinx-Mako - uses: .ryujinx-mako/.github/actions/setup-mako + uses: Ryujinx/Ryujinx-Mako/.github/actions/setup-mako@master ``` diff --git a/.github/actions/setup-mako/action.yml b/.github/actions/setup-mako/action.yml index a076da1..f1385b8 100644 --- a/.github/actions/setup-mako/action.yml +++ b/.github/actions/setup-mako/action.yml @@ -1,5 +1,5 @@ -name: 'Setup Ryujinx-Mako' -description: 'Setup the environment for Ryujinx-Mako' +name: 'Setup Mako' +description: 'Setup the environment for Mako' runs: using: 'composite' steps: @@ -7,6 +7,6 @@ runs: shell: bash - run: | - cd .ryujinx-mako + cd "${{ github.action_path }}/../" poetry install --only main shell: bash diff --git a/README.md b/README.md index 48cc75c..4255209 100644 --- a/README.md +++ b/README.md @@ -4,33 +4,18 @@ A custom GitHub App to aid Ryujinx with project management and moderation ## Usage -1. Add the following steps to your workflow: +Add the following step to your workflow: - ```yml - - name: Checkout Ryujinx-Mako - uses: actions/checkout@v3 - with: - repository: Ryujinx/Ryujinx-Mako - ref: master - path: '.ryujinx-mako' - - - name: Setup Ryujinx-Mako - uses: ./.ryujinx-mako/.github/actions/setup-mako - ``` - -2. Execute the available commands like this: - - ```yml - - name: Setup git identity for Ryujinx-Mako - run: | - # poetry -n -C .ryujinx-mako run ryujinx-mako [] - # for example: - poetry -n -C .ryujinx-mako run ryujinx-mako setup-git - env: - MAKO_APP_ID: ${{ secrets.MAKO_APP_ID }} - MAKO_PRIVATE_KEY: ${{ secrets.MAKO_PRIVATE_KEY }} - MAKO_INSTALLATION_ID: ${{ secrets.MAKO_INSTALLATION_ID }} - ``` +```yml +- name: Run Ryujinx-Mako + uses: Ryujinx/Ryujinx-Mako@master + with: + command: + args: + app_id: ${{ secrets.MAKO_APP_ID }} + private_key: ${{ secrets.MAKO_PRIVATE_KEY }} + installation_id: ${{ secrets.MAKO_INSTALLATION_ID }} +``` ## Available commands diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..7aad421 --- /dev/null +++ b/action.yml @@ -0,0 +1,47 @@ +name: 'Run Ryujinx-Mako' +description: 'Setup Mako and execute the specified subcommand' +inputs: + command: + description: 'Subcommand to execute with Mako' + required: true + args: + description: 'Arguments for the specified subcommand' + required: true + default: '' + app_id: + description: 'GitHub App ID' + required: true + private_key: + description: 'Private key for the GitHub App' + required: true + installation_id: + description: 'GitHub App Installation ID' + required: true +runs: + using: 'composite' + steps: + - name: Check if Mako was already setup + id: check_dest + run: | + [ -f "${{ github.action_path }}/.ryujinx-mako_setup-done" ] \ + && echo "exists=true" >> $GITHUB_OUTPUT \ + || echo "exists=false" >> $GITHUB_OUTPUT + shell: bash + + - name: Setup Mako + if: steps.check_dest.outputs.exists == "false" + uses: ./.github/actions/setup-mako + + - name: Create setup finished flag + if: steps.check_dest.outputs.exists == "false" + run: touch "${{ github.action_path }}/.ryujinx-mako_setup-done" + shell: bash + + - name: Run Mako subcommand + uses: ./.github/actions/execute-command + with: + command: ${{ inputs.command }} + args: ${{ inputs.args }} + app_id: ${{ inputs.app_id }} + private_key: ${{ inputs.private_key }} + installation_id: ${{ inputs.installation_id }}