From ac8efa2f5222a5d1eced936e55fa44fbc8e80e2c Mon Sep 17 00:00:00 2001 From: Sthope Date: Mon, 28 Aug 2023 18:40:26 +0200 Subject: [PATCH] Update .drone.yml --- .drone.yml | 55 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.drone.yml b/.drone.yml index c15561a..5646cf7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,32 +8,35 @@ steps: REPO_OWNER: "insignia-live" REPO_NAME: "setup-assistant-release" commands: - - echo "const axios = require('axios');" > script.js - - echo "" >> script.js - - echo "function getLatestReleaseTag() {" >> script.js - - echo " const repoOwner = process.env.REPO_OWNER;" >> script.js - - echo " const repoName = process.env.REPO_NAME;" >> script.js - - echo "" >> script.js - - echo " return axios" >> script.js - - echo " .get(\`https://api.github.com/repos/\${repoOwner}/\${repoName}/releases/latest\`)" >> script.js - - echo " .then((response) => response.data.tag_name)" >> script.js - - echo " .catch((error) => {" >> script.js - - echo " console.error('Error fetching latest release tag:', error.message);" >> script.js - - echo " return '0.0.0';" >> script.js - - echo " });" >> script.js - - echo "}" >> script.js - - echo "" >> script.js - - echo "getLatestReleaseTag().then((latestReleaseTag) => {" >> script.js - - echo " const targetReleaseTag = '2023-02-13-1223';" >> script.js - - echo "" >> script.js - - echo " if (latestReleaseTag > targetReleaseTag) {" >> script.js - - echo " console.log('This pipeline is run because the new release is newer than the one I have.');" >> script.js - - echo " } else if (latestReleaseTag === targetReleaseTag) {" >> script.js - - echo " console.log('The release tag is the same as the target tag.');" >> script.js - - echo " } else {" >> script.js - - echo " console.log('The new release is older than the one I have.');" >> script.js - - echo "}" >> script.js - - echo "" >> 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/\${repoOwner}/\${repoName}/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