diff options
author | CptAlanSmith <123112708+CptAlanSmith@users.noreply.github.com> | 2023-09-24 12:05:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-24 12:05:36 +0200 |
commit | a579fa30b9faced48499028f32e3ae53d7eeb142 (patch) | |
tree | d1e99c1e2ea0765d7c721851b89b8c9ef0c90af8 /.github/actions/openvic-env | |
parent | 0b4c30aa02c3ec1dacfc3ac190af4733531753ea (diff) | |
parent | cc3ced120cdb83b144f9c19d338cb354d15442e8 (diff) |
Merge pull request #158 from Spartan322/outsource/extras
Move actions and scripts to separate reusable repos
Diffstat (limited to '.github/actions/openvic-env')
-rw-r--r-- | .github/actions/openvic-env/action.yml | 13 | ||||
-rw-r--r-- | .github/actions/openvic-env/commit-environment.js | 30 | ||||
-rwxr-xr-x | .github/actions/openvic-env/url-environment.sh | 57 |
3 files changed, 0 insertions, 100 deletions
diff --git a/.github/actions/openvic-env/action.yml b/.github/actions/openvic-env/action.yml deleted file mode 100644 index 7c8c4e3..0000000 --- a/.github/actions/openvic-env/action.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Setup OpenVic Environment -description: Setup OpenVic Environment -runs: - using: "composite" - steps: - - name: Setup URL Environment - shell: bash - run: ${GITHUB_ACTION_PATH}/url-environment.sh - - - name: Setup Commit Environment - uses: actions/github-script@v6 - with: - script: require(`${process.env.GITHUB_ACTION_PATH}/commit-environment.js`)({github, context, core}) diff --git a/.github/actions/openvic-env/commit-environment.js b/.github/actions/openvic-env/commit-environment.js deleted file mode 100644 index f6213c2..0000000 --- a/.github/actions/openvic-env/commit-environment.js +++ /dev/null @@ -1,30 +0,0 @@ -module.exports = async ({github, context, core}) => { - const commit_name = 'OPENVIC_COMMIT'; - const tag_name = 'OPENVIC_TAG'; - const release_name = 'OPENVIC_RELEASE'; - var commit_sha = process.env["GITHUB_SHA"]; - - if(context.eventName === 'pull_request') { - commit_sha = context.payload.pull_request.head.sha; - } - - core.exportVariable(commit_name, commit_sha); - - try { - const release = await github.rest.repos.getLatestRelease({owner: context.repo.owner, repo: context.repo.repo}); - core.exportVariable(tag_name, release.data["tag_name"]); - core.exportVariable(release_name, release.data["name"]); - } catch(error) { - if (error.response.status != 404) throw error; - - const tagList = await github.rest.repos.listTags({owner: context.repo.owner, repo: context.repo.repo}); - if (tagList.data.length == 0) { - core.warning("Could not list tags, this repo has no tags on it, setting tag_name and release_name environment variables to '<UserRepo-NoTag>' and '<UserRepo-NoRelease>', you can fetch tags with 'git fetch --tags' <remote-name>' and push tags with 'git push --tags"); - core.exportVariable(tag_name, `<${context.repo.owner}/${context.repo.repo}-NoTag>`); - core.exportVariable(release_name, `<${context.repo.owner}/${context.repo.repo}-NoRelease>`); - } else { - core.exportVariable(tag_name, tagList.data[0].name); - core.exportVariable(release_name, tagList.data[0].name); - } - } -}
\ No newline at end of file diff --git a/.github/actions/openvic-env/url-environment.sh b/.github/actions/openvic-env/url-environment.sh deleted file mode 100755 index 352218b..0000000 --- a/.github/actions/openvic-env/url-environment.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# $1 = environment name -# $2 = value to set environment -set_var() { - if [[ -z ${!1+set} ]]; then - export $1=$2 - fi -} - -# $1 = left side -# $2 = right side -# returns $1 and $2 joined together with a single '/'' -join_path() { - result=$1 - if [[ $result == *"/" && $2 == "/"* ]]; then - result=${result%/} - fi - if [[ $result != *"/" && $2 != "/"* ]]; then - result="$result/" - fi - echo "$result$2" -} - -# $1 = environment name -set_github_var() { - if [ "${!1}" == "" ]; then - echo "::error::$1 environment variable has not been set." - elif ! curl -o /dev/null --head --silent --fail "${!1}"; then - echo "::error::${!1} does not exist." - else - echo "$1=${!1}" >> $GITHUB_ENV - fi -} - -if [[ $GODOT_BASE_DOWNLOAD_URL == *"downloads.tuxfamily.org/godotengine"* ]]; then - if [[ $GODOT_BASE_DOWNLOAD_URL != *"${GODOT_VERSION}"* ]]; then - GODOT_BASE_DOWNLOAD_URL="$(join_path ${GODOT_BASE_DOWNLOAD_URL} ${GODOT_VERSION})" - fi - if [[ $GODOT_VERSION_TYPE != "stable" ]]; then - GODOT_BASE_DOWNLOAD_URL="$(join_path ${GODOT_BASE_DOWNLOAD_URL} ${GODOT_VERSION_TYPE})" - fi - set_var GODOT_LINUX_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_linux.x86_64.zip")" - set_var GODOT_TEMPLATE_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_export_templates.tpz")" -elif [[ $GODOT_BASE_DOWNLOAD_URL == *"github.com/godotengine"* ]]; then - if [[ $GODOT_BASE_DOWNLOAD_URL != *"/releases"* ]]; then - GODOT_BASE_DOWNLOAD_URL=$(join_path $GODOT_BASE_DOWNLOAD_URL "releases") - fi - if [[ $GODOT_BASE_DOWNLOAD_URL != *"/download"* ]]; then - GODOT_BASE_DOWNLOAD_URL=$(join_path $GODOT_BASE_DOWNLOAD_URL "download") - fi - set_var GODOT_LINUX_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "${GODOT_VERSION}-${GODOT_VERSION_TYPE}/Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_linux.x86_64.zip")" - set_var GODOT_TEMPLATE_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "${GODOT_VERSION}-${GODOT_VERSION_TYPE}/Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_export_templates.tpz")" -fi - -set_github_var GODOT_LINUX_URL -set_github_var GODOT_TEMPLATE_URL
\ No newline at end of file |