aboutsummaryrefslogtreecommitdiff
path: root/.github/actions/openvic2-env
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-03-29 08:18:16 +0200
committer GitHub <noreply@github.com>2023-03-29 08:18:16 +0200
commit8f213935bdea2400b6809f9d5db45dde3416dedc (patch)
tree9d333d26e18e0ad29979170edc031f60866e40cd /.github/actions/openvic2-env
parentcb5858b80c6dc9918b8366a433ca78a5d4adebed (diff)
parent793a8939c4f721844c276a3d49293c23c902c8d3 (diff)
Merge pull request #79 from Spartan322/general-release-info
Diffstat (limited to '.github/actions/openvic2-env')
-rw-r--r--.github/actions/openvic2-env/action.yml27
1 files changed, 27 insertions, 0 deletions
diff --git a/.github/actions/openvic2-env/action.yml b/.github/actions/openvic2-env/action.yml
new file mode 100644
index 0000000..245777d
--- /dev/null
+++ b/.github/actions/openvic2-env/action.yml
@@ -0,0 +1,27 @@
+name: Setup OpenVic2 Environment
+description: Setup OpenVic2 Environment
+runs:
+ using: "composite"
+ steps:
+ - name: Setup Environment
+ uses: actions/github-script@v6
+ with:
+ script: |
+ const commit_name = 'OPENVIC2_COMMIT';
+ const tag_name = 'OPENVIC2_TAG';
+ const release_name = 'OPENVIC2_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});
+ core.exportVariable(tag_name, tagList.data[0].name);
+ core.exportVariable(release_name, tagList.data[0].name);
+ } \ No newline at end of file