Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add working directory to build plugin action, enable yarn 4 #28

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions build-plugin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ inputs:
description: "Version of node"
required: false
default: "20"
working-directory:
description: "The working directory where the plugin is located"
required: false
default: "."

runs:
using: "composite"
Expand All @@ -46,10 +50,12 @@ runs:
- name: Install dependencies
run: ${{ github.action_path }}/pm.sh install
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Build and test frontend
run: ${{ github.action_path }}/pm.sh build
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Check for backend
id: check-for-backend
Expand All @@ -59,20 +65,23 @@ runs:
echo "has-backend=true" >> $GITHUB_OUTPUT
fi
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: coverage
workdir: ${{ inputs.working-directory }}

- name: Build backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: buildAll
workdir: ${{ inputs.working-directory }}

- name: Warn missing Grafana access policy token
run: |
Expand All @@ -88,6 +97,7 @@ runs:
GRAFANA_ACCESS_POLICY_TOKEN: ${{ inputs.policy_token }}
GRAFANA_API_KEY: ${{ inputs.grafana_token }}
if: ${{ inputs.policy_token != '' }}
working-directory: ${{ inputs.working-directory }}

- name: Get plugin metadata
id: metadata
Expand All @@ -108,17 +118,20 @@ runs:

echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Read changelog
id: changelog
run: |
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
echo "path=release_notes.md" >> $GITHUB_OUTPUT
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Check package version
run: if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name. The tag should be v${{ steps.metadata.outputs.plugin-version }} \033[0m\n"; exit 1; fi
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Package plugin
id: package-plugin
Expand All @@ -127,6 +140,7 @@ runs:
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
sha1sum ${{ steps.metadata.outputs.archive }} | cut -f1 -d' ' > ${{ steps.metadata.outputs.archive-sha1sum }}
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Validate plugin
run: |
Expand All @@ -136,6 +150,7 @@ runs:
popd
plugincheck2 -config ./plugin-validator/config/default.yaml ${{ steps.metadata.outputs.archive }}
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Create Github release
uses: softprops/action-gh-release@v2
Expand All @@ -144,8 +159,8 @@ runs:
generate_release_notes: true
token: ${{ inputs.token }}
files: |
./${{ steps.metadata.outputs.archive }}
./${{ steps.metadata.outputs.archive-sha1sum }}
${{ inputs.working-directory }}/${{ steps.metadata.outputs.archive }}
${{ inputs.working-directory }}/${{ steps.metadata.outputs.archive-sha1sum }}
body: |
**This Github draft release has been created for your plugin.**

Expand Down
2 changes: 2 additions & 0 deletions build-plugin/pm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ install_pnpm_if_not_present() {
fi
}

corepack enable

# Detect the package manager
if [ -f yarn.lock ]; then
pm="yarn"
Expand Down