File: /home/enamadmin/public_html/aaelearningb/enrol/attributes/.github/workflows/moodle-release.yml
#
# Whenever a new tag is pushed, add the tagged version
# to the Moodle Plugins directory at https://moodle.org/plugins
#
name: Releasing in the Plugins directory
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to be released'
required: true
defaults:
run:
shell: bash
jobs:
release-at-moodle-org:
runs-on: ubuntu-latest
env:
PLUGIN: enrol_attributes
CURL: curl -s
ENDPOINT_TOKEN: https://moodle.org/login/token.php
ENDPOINT_REST: https://moodle.org/webservice/rest/server.php
USERNAME: ${{ secrets.MOODLE_ORG_USERNAME }}
PASSWORD: ${{ secrets.MOODLE_ORG_PASSWORD }}
SERVICE: plugins_maintenance
FUNCTION: local_plugins_add_version
steps:
- name: Authenticate and obtain service token
id: get-token
run: |
RESPONSE=$(${CURL} ${ENDPOINT_TOKEN} --data "username=${USERNAME}&password=${PASSWORD}&service=${SERVICE}")
TOKEN=$(jq --raw-output ".token" <<< ${RESPONSE})
if [[ $? > 0 ]]; then
echo "Error parsing JSON response:"
echo "${RESPONSE}"
exit 1
fi
echo "::add-mask::$TOKEN"
echo "TOKEN=${TOKEN}" >> $GITHUB_ENV
- name: Call the service function
id: add-version
run: |
if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then
TAGNAME="${{ github.event.inputs.tag }}"
elif [[ $GITHUB_REF = refs/tags/* ]]; then
TAGNAME="${GITHUB_REF##*/}"
fi
if [[ -z "${TAGNAME}" ]]; then
echo "No tag name has been provided!"
exit 1
fi
ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}"
RESPONSE=$(${CURL} ${ENDPOINT_REST} --data "wstoken=${TOKEN}&wsfunction=${FUNCTION}&moodlewsrestformat=json&frankenstyle=${PLUGIN}&zipurl=${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