-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ci/run-ci-on-release
- Loading branch information
Showing
8 changed files
with
140 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ on: | |
release: | ||
types: | ||
- published | ||
- prereleased | ||
|
||
permissions: | ||
pull-requests: write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
name: release | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
pr: none | ||
trigger: | ||
tags: | ||
include: | ||
- 'v*' | ||
|
||
pool: | ||
vmImage: ubuntu-latest | ||
|
||
variables: | ||
TAG: $[replace(variables['Build.SourceBranch'], 'refs/tags/', '')] | ||
|
||
steps: | ||
- script: echo $TAG | ||
displayName: 'Output tag' | ||
env: | ||
TAG: $(TAG) | ||
- script: yarn install --ignore-engines && npx playwright install && yarn global add ts-node | ||
displayName: 'Install dependencies' | ||
- script: ts-node scripts/downloadGithubReleasePackage.ts | ||
displayName: 'Download release artifact from GitHub' | ||
env: | ||
TAG: $(TAG) | ||
- script: yarn build:example-website | ||
displayName: 'Build website' | ||
env: | ||
VITE_API_KEY: $(API_KEY) | ||
VITE_ENDPOINT: $(VITE_ENDPOINT) | ||
VITE_SCRIPT_URL_PATTERN: $(VITE_SCRIPT_URL_PATTERN) | ||
NODE_OPTIONS: "--max_old_space_size=16384" | ||
|
||
- task: AzureCLI@2 | ||
displayName: 'Deploy infrastructure' | ||
env: | ||
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME) | ||
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME) | ||
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP) | ||
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID) | ||
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET) | ||
inputs: | ||
azureSubscription: 'azure-proxy-integration-e2e-tests' | ||
scriptType: 'bash' | ||
scriptLocation: 'inlineScript' | ||
inlineScript: 'yarn e2e-deploy-infra' | ||
|
||
- task: AzureCLI@2 | ||
inputs: | ||
azureSubscription: 'azure-proxy-integration-e2e-tests' | ||
scriptType: 'bash' | ||
scriptLocation: 'inlineScript' | ||
inlineScript: 'yarn test:e2e' | ||
displayName: 'Run e2e tests' | ||
env: | ||
CI: 'true' | ||
|
||
- task: AzureCLI@2 | ||
inputs: | ||
azureSubscription: 'azure-proxy-integration-e2e-tests' | ||
scriptType: 'bash' | ||
scriptLocation: 'inlineScript' | ||
inlineScript: 'yarn e2e-destroy-infra' | ||
displayName: 'Destroy infrastructure' | ||
condition: always() | ||
env: | ||
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME) | ||
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME) | ||
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP) | ||
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID) | ||
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
trigger: | ||
branches: | ||
exclude: | ||
- 'test' | ||
include: | ||
- '*' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { config } from '../management/config' | ||
import { bearer, downloadReleaseAsset, findFunctionZip, GithubRelease } from '../management/github' | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
async function main() { | ||
const tag = process.env.TAG | ||
const token = process.env.GITHUB_TOKEN | ||
|
||
if (!tag) { | ||
throw new Error('TAG environment variable is required') | ||
} | ||
|
||
console.debug('tag', tag) | ||
|
||
const url = `https://api.github.com/repos/${config.repositoryOwner}/${config.repository}/releases/tags/${tag}` | ||
|
||
console.debug('url', url) | ||
|
||
const githubRelease: GithubRelease = await fetch(url, { | ||
headers: token | ||
? { | ||
Authorization: bearer(token), | ||
} | ||
: undefined, | ||
}).then((res) => res.json()) | ||
|
||
console.debug('githubRelease', githubRelease) | ||
|
||
const functionZip = await findFunctionZip(githubRelease.assets) | ||
|
||
console.debug('functionZip', functionZip) | ||
|
||
if (!functionZip) { | ||
throw new Error('No function zip found') | ||
} | ||
|
||
const asset = await downloadReleaseAsset(functionZip.url, token) | ||
|
||
fs.writeFileSync(path.resolve(__dirname, '../package.zip'), asset) | ||
} | ||
|
||
main().catch((err) => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["node"], | ||
"module": "CommonJS" | ||
}, | ||
"exclude": [ | ||
"../dist", | ||
"node_modules", | ||
"**/*.test.ts", | ||
"test", | ||
"e2e" | ||
], | ||
"include": [ | ||
"scripts/**.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters