File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424 required : true
2525 OVH_PASSWORD :
2626 required : true
27+ MIXXX_WEBSITE_ENV_CLEANUP_PAT :
28+ required : true
2729
2830jobs :
2931 apply :
32+ name : ${{ format('{0} environment "{1}"', inputs.action == 'teardown' && 'Tearing down' || 'Deploying', inputs.environment_name) }}
3033 runs-on : ubuntu-latest
3134 concurrency :
3235 group : website-ovh-${{ inputs.target }}
@@ -128,3 +131,30 @@ jobs:
128131 mkdir empty
129132 ssh-keyscan "${OVH_HOSTNAME}" >> "${HOME}/.ssh/known_hosts"
130133 lftp --env-password -u ${OVH_USERNAME} sftp://${OVH_HOSTNAME} -e "set sftp:connect-program \"ssh -o Compression=no\"; set mirror:parallel-transfer-count 16; set mirror:parallel-directories yes; mirror -vv --delete -P 16 -R ./empty /home/${OVH_USERNAME}/${TARGET}; rmdir /home/${OVH_USERNAME}/${TARGET}; quit"
134+
135+ - name : Deleting environment
136+ if : ${{ inputs.action == 'teardown' && inputs.target != 'www' }}
137+ env :
138+ ENVIRONMENT_NAME : ${{ inputs.environment_name }}
139+ uses : actions/github-script@v9
140+ with :
141+ github-token : ${{ secrets.MIXXX_WEBSITE_ENV_CLEANUP_PAT }}
142+ script : |
143+ const environment = process.env.ENVIRONMENT_NAME;
144+
145+ try {
146+
147+ await github.rest.repos.deleteAnEnvironment({
148+ owner: context.repo.owner,
149+ repo: context.repo.repo,
150+ environment_name: environment,
151+ });
152+
153+ console.log(`Deleted environment '${environment}'`);
154+ } catch (err) {
155+ if (err.status === 404) {
156+ console.log(`Environment '${environment}' does not exist.`);
157+ } else {
158+ throw err;
159+ }
160+ }
You can’t perform that action at this time.
0 commit comments