Skip to content

Commit

Permalink
Merge pull request #843 from datacite/add-env-var
Browse files Browse the repository at this point in the history
Add HANDLE_SERVER env variable.
  • Loading branch information
svogt0511 authored Feb 1, 2024
2 parents c9213e8 + 1ded7f2 commit 45e6fba
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 16 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ STAFF_ADMIN_PASSWORD=
ORGANIZATION_ADMIN_PASSWORD=
CONSORTIUM_ADMIN_PASSWORD=
CLIENT_ADMIN_PASSWORD=
HANDLE_URL=https://handle.stage.datacite.org
3 changes: 2 additions & 1 deletion .github/workflows/branch_to_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
deploy:
needs: [call_build, ember_test, cypress_test]
runs-on: ubuntu-latest
environment: vercel-bracco-preview
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
Expand All @@ -43,6 +44,6 @@ jobs:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
scope: ${{ secrets.TEAM_ID}}
vercel-project-name: 'bracco'
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
deploy:
needs: [call_build, ember_test, cypress_test]
runs-on: ubuntu-latest
environment: vercel-bracco-preview
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
Expand All @@ -45,7 +46,7 @@ jobs:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
scope: ${{ secrets.TEAM_ID}}
vercel-project-name: 'bracco'
alias-domains: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/preview-app-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jobs:
deploy:
if: ${{ github.event.label.name == 'create preview app' }}
runs-on: ubuntu-latest
environment: vercel-bracco-preview
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
Expand All @@ -17,7 +18,7 @@ jobs:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--force' || '' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
scope: ${{ secrets.TEAM_ID}}
vercel-project-name: 'bracco'
github-comment: true
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:
uses: ./.github/workflows/cypress_test.yml
secrets: inherit

deploy:
deploy-to-production:
needs: [call_build, ember_test, cypress_test]
runs-on: ubuntu-latest
environment: vercel-bracco-production
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
Expand All @@ -44,16 +45,34 @@ jobs:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
scope: ${{ secrets.TEAM_ID}}
vercel-project-name: 'bracco'

deploy-to-test:
needs: [call_build, ember_test, cypress_test]
runs-on: ubuntu-latest
environment: vercel-bracco-test
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Extract variables
shell: bash
run: |
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_OUTPUT
echo "GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "GIT_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: extract_variables

- name: Vercel deploy test
uses: amondnet/[email protected]
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.TEST_PROJECT_ID}}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }}
vercel-args: ${{ vars.VERCEL_NOCACHE == 'true' && '--prod --force' || '--prod' }} --build-env HANDLE_SERVER=${{vars.HANDLE_SERVER}}
scope: ${{ secrets.TEAM_ID}}
vercel-project-name: 'bracco-test'
6 changes: 1 addition & 5 deletions app/models/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,7 @@ export default Model.extend(Validations, {
downloadCount: attr('number'),

identifier: computed('doi', 'repository', function () {
if (ENV.API_URL == 'https://api.datacite.org') {
return 'https://doi.org/' + this.doi;
} else {
return 'https://handle.stage.datacite.org/' + this.doi;
}
return ENV.HANDLE_SERVER + '/' + this.doi;
}),
isDraft: equal('state', 'draft'),
showCitation: reads('registered'),
Expand Down
18 changes: 15 additions & 3 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* eslint-env node */
'use strict';

function normalizeURL(val) {
return val.trim().replace(/\/$/, '');
}

module.exports = function (environment) {
const pkg = require('../package.json');

Expand Down Expand Up @@ -74,7 +78,7 @@ module.exports = function (environment) {
'https://[email protected]/1420435',

disablePerformance: true,
environment: fabricaDeployTarget || "stage"
environment: fabricaDeployTarget || 'stage'
}
},
'ember-cli-string-helpers': {
Expand Down Expand Up @@ -148,14 +152,21 @@ module.exports = function (environment) {
// when it is created
},

MIN_PREFIXES_AVAILABLE: minPrefixesAvailable,
MIN_PREFIXES_AVAILABLE: minPrefixesAvailable,
SHOW_N_PREFIXES: showNPrefixes,
MAX_MINT_FUTURE_OFFSET: maxMintFutureOffset
MAX_MINT_FUTURE_OFFSET: maxMintFutureOffset,
HANDLE_SERVER: ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.stage.datacite.org' : normalizeURL(process.env.HANDLE_SERVER)
};

if (fabricaDeployTarget === 'stage') {
// add staging-specific settings here
ENV.COOKIE_DOMAIN = '.stage.datacite.org';
ENV.HANDLE_SERVER = ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.stage.datacite.org' : normalizeURL(process.env.HANDLE_SERVER);
}

if (fabricaDeployTarget === 'test') {
// add test-env-specific settings here
ENV.HANDLE_SERVER = ((typeof process.env.HANDLE_SERVER === 'undefined') || (process.env.HANDLE_SERVER == "")) ? 'https://handle.test.datacite.org' : normalizeURL(process.env.HANDLE_SERVER);
}

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

// Environment named 'test' here is the ember environment, not related to fabrica environments.
Expand Down
6 changes: 4 additions & 2 deletions dotenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module.exports = function () {
'ENABLE_DOI_ESTIMATE',
'MIN_PREFIXES_AVAILABLE',
'MAX_MINT_FUTURE_OFFSET',
'SHOW_N_PREFIXES'
'SHOW_N_PREFIXES',
'HANDLE_SERVER'
],
fastbootAllowedKeys: [
'SITE_TITLE',
Expand Down Expand Up @@ -60,7 +61,8 @@ module.exports = function () {
'ENABLE_DOI_ESTIMATE',
'MIN_PREFIXES_AVAILABLE',
'MAX_MINT_FUTURE_OFFSET',
'SHOW_N_PREFIXES'
'SHOW_N_PREFIXES',
'HANDLE_SERVER'
],
failOnMissingKey: false
};
Expand Down

0 comments on commit 45e6fba

Please sign in to comment.