From 0d5778d6a7112a979e41a9a675d6ab38580c026b Mon Sep 17 00:00:00 2001 From: Sthope Date: Mon, 28 Aug 2023 19:03:34 +0200 Subject: [PATCH] Update .drone.yml --- .drone.yml | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/.drone.yml b/.drone.yml index 211b73e..44e8cc0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,31 +5,37 @@ steps: - name: create-script-file image: alpine:3.13 commands: - - echo "const axios = require('axios');" > custom-script.js - - echo "" >> custom-script.js - - echo "function getLatestReleaseTag() {" >> custom-script.js - - echo " return axios" >> custom-script.js - - echo " .get('https://api.github.com/repos/insignia-live/setup-assistant-release/releases/latest')" >> custom-script.js - - echo " .then((response) => response.data.tag_name)" >> custom-script.js - - echo " .catch((error) => {" >> custom-script.js - - echo " console.error('Error fetching latest release tag:', error.message);" >> custom-script.js - - echo " return '0.0.0';" >> custom-script.js - - echo " });" >> custom-script.js - - echo "}" >> custom-script.js - - echo "" >> custom-script.js - - echo "getLatestReleaseTag().then((latestReleaseTag) => {" >> custom-script.js - - echo " const targetReleaseTag = '2023-02-13-1223';" >> custom-script.js - - echo "" >> custom-script.js - - echo " if (latestReleaseTag > targetReleaseTag) {" >> custom-script.js - - echo " console.log('This pipeline is run because the new release is newer than the one I have.');" >> custom-script.js - - echo " } else if (latestReleaseTag === targetReleaseTag) {" >> custom-script.js - - echo " console.log('The release tag is the same as the target tag.');" >> custom-script.js - - echo " } else {" >> custom-script.js - - echo " console.log('The new release is older than the one I have.');" >> custom-script.js - - echo "}" >> custom-script.js - - echo "" >> custom-script.js + - cat < script.js + const axios = require('axios'); + + function getLatestReleaseTag() { + const repoOwner = process.env.REPO_OWNER; + const repoName = process.env.REPO_NAME; + + return axios + .get(\`https://api.github.com/repos/insignia-live/setup-assistant-release/releases/latest\`) + .then((response) => response.data.tag_name) + .catch((error) => { + console.error('Error fetching latest release tag:', error.message); + return '0.0.0'; + }); + } + + getLatestReleaseTag().then((latestReleaseTag) => { + const targetReleaseTag = '2023-02-13-1223'; + + if (latestReleaseTag > targetReleaseTag) { + console.log('This pipeline is run because the new release is newer than the one I have.'); + } else if (latestReleaseTag === targetReleaseTag) { + console.log('The release tag is the same as the target tag.'); + } else { + console.log('The new release is older than the one I have.'); + } + }); + EOF + - chmod +x script.js - name: run image: node:14 commands: - - node custom-script.js \ No newline at end of file + - node script.js