From b5d76a428a88fd48bc4ec4731bfa25dc638994f0 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Tue, 10 Aug 2021 20:32:42 +1200 Subject: [PATCH] add github action for moodle plugin release. --- .github/workflows/moodle-release.yml | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/moodle-release.yml diff --git a/.github/workflows/moodle-release.yml b/.github/workflows/moodle-release.yml new file mode 100644 index 0000000..dda255c --- /dev/null +++ b/.github/workflows/moodle-release.yml @@ -0,0 +1,51 @@ +# +# Whenever version.php is changed, add the latest version +# to the Moodle Plugins directory at https://moodle.org/plugins +# +# revision: 2021070201 +# +name: Releasing in the Plugins directory + +on: + push: + paths: + - '/version.php' + +defaults: + run: + shell: bash + +jobs: + release-at-moodle-org: + runs-on: ubuntu-latest + env: + PLUGIN: mod_attendance + BRANCH: MOODLE_311_STABLE + CURL: curl -s + ENDPOINT: https://moodle.org/webservice/rest/server.php + TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }} + FUNCTION: local_plugins_add_version + + steps: + - name: Call the service function + id: add-version + run: | + ZIPURL="https://github.com/danmarsden/moodle-mod_attendance/archive/refs/heads/{BRANCH}.zip" + RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \ + --data-urlencode "wsfunction=${FUNCTION}" \ + --data-urlencode "moodlewsrestformat=json" \ + --data-urlencode "frankenstyle=${PLUGIN}" \ + --data-urlencode "zipurl=${ZIPURL}" \ + --data-urlencode "vcssystem=git" \ + --data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \ + --data-urlencode "vcstag=${TAGNAME}" \ + --data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/{BRANCH}" \ + --data-urlencode "altdownloadurl=${ZIPURL}") + echo "::set-output name=response::${RESPONSE}" + - name: Evaluate the response + id: evaluate-response + env: + RESPONSE: ${{ steps.add-version.outputs.response }} + run: | + jq <<< ${RESPONSE} + jq --exit-status ".id" <<< ${RESPONSE} > /dev/null