Skip to content

Commit 45e6fba

Browse files
authored
Merge pull request #843 from datacite/add-env-var
Add HANDLE_SERVER env variable.
2 parents c9213e8 + 1ded7f2 commit 45e6fba

8 files changed

Lines changed: 49 additions & 16 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ STAFF_ADMIN_PASSWORD=
1414
ORGANIZATION_ADMIN_PASSWORD=
1515
CONSORTIUM_ADMIN_PASSWORD=
1616
CLIENT_ADMIN_PASSWORD=
17+
HANDLE_URL=https://handle.stage.datacite.org

.github/workflows/branch_to_staging.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
deploy:
2424
needs: [call_build, ember_test, cypress_test]
2525
runs-on: ubuntu-latest
26+
environment: vercel-bracco-preview
2627
env:
2728
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2829
steps:
@@ -43,6 +44,6 @@ jobs:
4344
vercel-token: ${{ secrets.VERCEL_TOKEN }}
4445
vercel-org-id: ${{ secrets.ORG_ID}}
4546
vercel-project-id: ${{ secrets.PROJECT_ID}}
46-
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }}
47+
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
4748
scope: ${{ secrets.TEAM_ID}}
4849
vercel-project-name: 'bracco'

.github/workflows/deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
deploy:
2626
needs: [call_build, ember_test, cypress_test]
2727
runs-on: ubuntu-latest
28+
environment: vercel-bracco-preview
2829
env:
2930
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
3031
steps:
@@ -45,7 +46,7 @@ jobs:
4546
vercel-token: ${{ secrets.VERCEL_TOKEN }}
4647
vercel-org-id: ${{ secrets.ORG_ID}}
4748
vercel-project-id: ${{ secrets.PROJECT_ID}}
48-
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }}
49+
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
4950
scope: ${{ secrets.TEAM_ID}}
5051
vercel-project-name: 'bracco'
5152
alias-domains: |

.github/workflows/preview-app-label.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ jobs:
66
deploy:
77
if: ${{ github.event.label.name == 'create preview app' }}
88
runs-on: ubuntu-latest
9+
environment: vercel-bracco-preview
910
env:
1011
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
1112
steps:
@@ -17,7 +18,7 @@ jobs:
1718
vercel-token: ${{ secrets.VERCEL_TOKEN }}
1819
vercel-org-id: ${{ secrets.ORG_ID}}
1920
vercel-project-id: ${{ secrets.PROJECT_ID}}
20-
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }}
21+
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
2122
scope: ${{ secrets.TEAM_ID}}
2223
vercel-project-name: 'bracco'
2324
github-comment: true

.github/workflows/release.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ jobs:
2121
uses: ./.github/workflows/cypress_test.yml
2222
secrets: inherit
2323

24-
deploy:
24+
deploy-to-production:
2525
needs: [call_build, ember_test, cypress_test]
2626
runs-on: ubuntu-latest
27+
environment: vercel-bracco-production
2728
env:
2829
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2930
steps:
@@ -44,16 +45,34 @@ jobs:
4445
vercel-token: ${{ secrets.VERCEL_TOKEN }}
4546
vercel-org-id: ${{ secrets.ORG_ID}}
4647
vercel-project-id: ${{ secrets.PROJECT_ID}}
47-
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }}
48+
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
4849
scope: ${{ secrets.TEAM_ID}}
4950
vercel-project-name: 'bracco'
5051

52+
deploy-to-test:
53+
needs: [call_build, ember_test, cypress_test]
54+
runs-on: ubuntu-latest
55+
environment: vercel-bracco-test
56+
env:
57+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v3
61+
62+
- name: Extract variables
63+
shell: bash
64+
run: |
65+
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_OUTPUT
66+
echo "GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
67+
echo "GIT_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
68+
id: extract_variables
69+
5170
- name: Vercel deploy test
5271
uses: amondnet/vercel-action@v25.1.1
5372
with:
5473
vercel-token: ${{ secrets.VERCEL_TOKEN }}
5574
vercel-org-id: ${{ secrets.ORG_ID}}
5675
vercel-project-id: ${{ secrets.TEST_PROJECT_ID}}
57-
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }}
76+
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
5877
scope: ${{ secrets.TEAM_ID}}
5978
vercel-project-name: 'bracco-test'

app/models/doi.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ export default Model.extend(Validations, {
212212
downloadCount: attr('number'),
213213

214214
identifier: computed('doi', 'repository', function () {
215-
if (ENV.API_URL == 'https://api.datacite.org') {
216-
return 'https://doi.org/' + this.doi;
217-
} else {
218-
return 'https://handle.stage.datacite.org/' + this.doi;
219-
}
215+
return ENV.HANDLE_SERVER + '/' + this.doi;
220216
}),
221217
isDraft: equal('state', 'draft'),
222218
showCitation: reads('registered'),

config/environment.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/* eslint-env node */
22
'use strict';
33

4+
function normalizeURL(val) {
5+
return val.trim().replace(/\/$/, '');
6+
}
7+
48
module.exports = function (environment) {
59
const pkg = require('../package.json');
610

@@ -74,7 +78,7 @@ module.exports = function (environment) {
7478
'https://63201db022924202b697e03bc5e0d0ba@o239790.ingest.sentry.io/1420435',
7579

7680
disablePerformance: true,
77-
environment: fabricaDeployTarget || "stage"
81+
environment: fabricaDeployTarget || 'stage'
7882
}
7983
},
8084
'ember-cli-string-helpers': {
@@ -148,14 +152,21 @@ module.exports = function (environment) {
148152
// when it is created
149153
},
150154

151-
MIN_PREFIXES_AVAILABLE: minPrefixesAvailable,
155+
MIN_PREFIXES_AVAILABLE: minPrefixesAvailable,
152156
SHOW_N_PREFIXES: showNPrefixes,
153-
MAX_MINT_FUTURE_OFFSET: maxMintFutureOffset
157+
MAX_MINT_FUTURE_OFFSET: maxMintFutureOffset,
158+
HANDLE_SERVER: ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.stage.datacite.org' : normalizeURL(process.env.HANDLE_SERVER)
154159
};
155160

156161
if (fabricaDeployTarget === 'stage') {
157162
// add staging-specific settings here
158163
ENV.COOKIE_DOMAIN = '.stage.datacite.org';
164+
ENV.HANDLE_SERVER = ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.stage.datacite.org' : normalizeURL(process.env.HANDLE_SERVER);
165+
}
166+
167+
if (fabricaDeployTarget === 'test') {
168+
// add test-env-specific settings here
169+
ENV.HANDLE_SERVER = ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.test.datacite.org' : normalizeURL(process.env.HANDLE_SERVER);
159170
}
160171

161172
if (fabricaDeployTarget === 'production') {
@@ -169,6 +180,7 @@ module.exports = function (environment) {
169180
ENV.CDN_URL = 'https://assets.datacite.org';
170181
ENV.HOME_URL = 'https://datacite.org';
171182
ENV.COOKIE_DOMAIN = '.datacite.org';
183+
ENV.HANDLE_SERVER = ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://doi.org' : normalizeURL(process.env.HANDLE_SERVER);
172184
}
173185

174186
// Environment named 'test' here is the ember environment, not related to fabrica environments.

dotenv.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ module.exports = function () {
2929
'ENABLE_DOI_ESTIMATE',
3030
'MIN_PREFIXES_AVAILABLE',
3131
'MAX_MINT_FUTURE_OFFSET',
32-
'SHOW_N_PREFIXES'
32+
'SHOW_N_PREFIXES',
33+
'HANDLE_SERVER'
3334
],
3435
fastbootAllowedKeys: [
3536
'SITE_TITLE',
@@ -60,7 +61,8 @@ module.exports = function () {
6061
'ENABLE_DOI_ESTIMATE',
6162
'MIN_PREFIXES_AVAILABLE',
6263
'MAX_MINT_FUTURE_OFFSET',
63-
'SHOW_N_PREFIXES'
64+
'SHOW_N_PREFIXES',
65+
'HANDLE_SERVER'
6466
],
6567
failOnMissingKey: false
6668
};

0 commit comments

Comments
 (0)