-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.0 - Extracted reusable sub-workflows (#4)
Co-authored-by: ponlawat-w <[email protected]>
- Loading branch information
1 parent
1993b7e
commit ddb6af7
Showing
5 changed files
with
170 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Get Widget Versions | ||
on: | ||
workflow_call: | ||
outputs: | ||
widget-backgroundcolour-branch: | ||
description: Branch name of background colour widget | ||
value: ${{ jobs.widget-versions.outputs.widget-backgroundcolour-branch }} | ||
widget-fontface-branch: | ||
description: Branch name of font face widget | ||
value: ${{ jobs.widget-versions.outputs.widget-fontface-branch }} | ||
widget-fontsize-branch: | ||
description: Branch name of font size widget | ||
value: ${{ jobs.widget-versions.outputs.widget-fontsize-branch }} | ||
widget-textcolour-branch: | ||
description: Branch name of text colour widget | ||
value: ${{ jobs.widget-versions.outputs.widget-textcolour-branch }} | ||
jobs: | ||
widget-versions: | ||
name: Get default widget versions | ||
runs-on: ubuntu-latest | ||
outputs: | ||
widget-backgroundcolour-branch: ${{ steps.widget-branches.outputs.WIDGET_BACKGROUNDCOLOUR_VERSION }} | ||
widget-fontface-branch: ${{ steps.widget-branches.outputs.WIDGET_FONTFACE_VERSION }} | ||
widget-fontsize-branch: ${{ steps.widget-branches.outputs.WIDGET_FONTSIZE_VERSION }} | ||
widget-textcolour-branch: ${{ steps.widget-branches.outputs.WIDGET_TEXTCOLOUR_VERSION }} | ||
steps: | ||
- name: Get widget version | ||
id: get-widget-versions | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
echo "WIDGET_BACKGROUNDCOLOUR_VERSION_JSON=$(gh release view --json name -R ponlawat-w/moodle-accessibility_backgroundcolour)" >> $GITHUB_OUTPUT | ||
echo "WIDGET_FONTFACE_VERSION_JSON=$(gh release view --json name -R ponlawat-w/moodle-accessibility_fontface)" >> $GITHUB_OUTPUT | ||
echo "WIDGET_FONTSIZE_VERSION_JSON=$(gh release view --json name -R ponlawat-w/moodle-accessibility_fontsize)" >> $GITHUB_OUTPUT | ||
echo "WIDGET_TEXTCOLOUR_VERSION_JSON=$(gh release view --json name -R ponlawat-w/moodle-accessibility_textcolour)" >> $GITHUB_OUTPUT | ||
- name: Get widget branch names | ||
id: widget-branches | ||
run: | | ||
echo "WIDGET_BACKGROUNDCOLOUR_VERSION=v${{ fromJson(steps.get-widget-versions.outputs.WIDGET_BACKGROUNDCOLOUR_VERSION_JSON).name }}" >> $GITHUB_OUTPUT | ||
echo "WIDGET_FONTFACE_VERSION=v${{ fromJson(steps.get-widget-versions.outputs.WIDGET_FONTFACE_VERSION_JSON).name }}" >> $GITHUB_OUTPUT | ||
echo "WIDGET_FONTSIZE_VERSION=v${{ fromJson(steps.get-widget-versions.outputs.WIDGET_FONTSIZE_VERSION_JSON).name }}" >> $GITHUB_OUTPUT | ||
echo "WIDGET_TEXTCOLOUR_VERSION=v${{ fromJson(steps.get-widget-versions.outputs.WIDGET_TEXTCOLOUR_VERSION_JSON).name }}" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Retrieve Plugin Version from version.php | ||
on: | ||
workflow_call: | ||
inputs: | ||
repository: | ||
type: string | ||
default: ${{ github.repository }} | ||
ref: | ||
type: string | ||
default: '' | ||
outputs: | ||
plugin-component: | ||
description: Plugin component | ||
value: ${{ jobs.get-version.outputs.plugin-component }} | ||
plugin-release: | ||
description: Plugin release | ||
value: ${{ jobs.get-version.outputs.plugin-release }} | ||
plugin-version: | ||
description: Plugin version | ||
value: ${{ jobs.get-version.outputs.plugin-version }} | ||
plugin-requires: | ||
description: Plugin requires | ||
value: ${{ jobs.get-version.outputs.plugin-requires }} | ||
plugin-maturity: | ||
description: Plugin maturity | ||
value: ${{ jobs.get-version.outputs.plugin-maturity }} | ||
plugin-dependencies: | ||
description: Plugin dependencies (JSON text) | ||
value: ${{ jobs.get-version.outputs.plugin-dependencies }} | ||
branch-name: | ||
description: Branch name | ||
value: ${{ jobs.get-version.outputs.branch-name }} | ||
jobs: | ||
get-version: | ||
name: Get plugin version from version.php | ||
runs-on: ubuntu-latest | ||
outputs: | ||
plugin-component: ${{ steps.plugin-info.outputs.PLUGIN_COMPONENT }} | ||
plugin-release: ${{ steps.plugin-info.outputs.PLUGIN_RELEASE }} | ||
plugin-version: ${{ steps.plugin-info.outputs.PLUGIN_VERSION }} | ||
plugin-requires: ${{ steps.plugin-info.outputs.PLUGIN_REQUIRES }} | ||
plugin-maturity: ${{ steps.plugin-info.outputs.PLUGIN_MATURITY }} | ||
plugin-dependencies: ${{ steps.plugin-info.outputs.PLUGIN_DEPENDENCIES }} | ||
branch-name: ${{ steps.get-branch.outputs.BRANCH_NAME }} | ||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.0 | ||
extensions: | ||
ini-values: max_input_vars=5000 | ||
coverage: none | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ inputs.repository }} | ||
ref: ${{ inputs.ref }} | ||
- name: Get plugin information | ||
id: plugin-info | ||
run: php -r 'define("MOODLE_INTERNAL",1);define("MATURITY_ALPHA",50);define("MATURITY_BETA",100);define("MATURITY_RC",150);define("MATURITY_STABLE",200);define("ANY_VERSION","any");$plugin=new stdClass();include_once("version.php");$plugin->maturity!=200&&throw new Exception("Requires plugin maturity to be stable to release!");echo "PLUGIN_COMPONENT=".(isset($plugin->component)?$plugin->component:"")."\nPLUGIN_RELEASE=".(isset($plugin->release)?$plugin->release:"")."\nPLUGIN_VERSION=".(isset($plugin->version)?$plugin->version:"")."\nPLUGIN_REQUIRES=".(isset($plugin->requires)?$plugin->requires:"")."\nPLUGIN_MATURITY=".(isset($plugin->maturity)?$plugin->maturity:"")."\nPLUGIN_DEPENDENCIES=".(isset($plugin->dependencies)?json_encode($plugin->dependencies):"{}");' >> $GITHUB_OUTPUT | ||
- name: Get branch name | ||
id: get-branch | ||
run: php -r 'echo "BRANCH_NAME=".preg_replace("/(\\(|\\))/", "", strtolower(str_replace(" ", "-", preg_replace("/(\\d+)\\.(\\d+)\\.(\\d+)(.*)/","v$1.$2$4", "${{ steps.plugin-info.outputs.PLUGIN_RELEASE }}"))));' >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.