Skip to content

Commit

Permalink
fix: fix custom-domain and github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rsonghuster committed Aug 7, 2024
1 parent 06c6dcd commit b37b344
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 18 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci_node16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
- name: config s
run: |
s config add --AccountID ${{secrets.ACCOUNTID}} --AccountID ${{secrets.ACCOUNTID}} --AccessKeyID ${{secrets.ACCESSKEYID}} --AccessKeySecret ${{secrets.ACCESSKEYSECRET}} -a quanxi -f
- name: Configure NPM
run: |
npm config set registry https://registry.npmjs.org
npm config set '//packages.aliyun.com/6455f7ff81b284e28f4774c4/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}}
- name: NPM install
run: |
npm install
Expand Down Expand Up @@ -76,6 +80,10 @@ jobs:
- name: config s
run: |
s config add --AccountID ${{secrets.ACCOUNTID}} --AccessKeyID ${{secrets.ACCESSKEYID}} --AccessKeySecret ${{secrets.ACCESSKEYSECRET}} -a quanxi -f
- name: Configure NPM
run: |
npm config set registry https://registry.npmjs.org
npm config set '//packages.aliyun.com/6455f7ff81b284e28f4774c4/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}}
- name: NPM install
run: |
npm install
Expand Down Expand Up @@ -113,9 +121,12 @@ jobs:
- name: config s
run: |
s config add --AccountID ${{secrets.ACCOUNTID}} --AccessKeyID ${{secrets.ACCESSKEYID}} --AccessKeySecret ${{secrets.ACCESSKEYSECRET}} -a quanxi -f
- name: Configure NPM
run: |
npm config set registry https://registry.npmjs.org
npm config set '//packages.aliyun.com/6455f7ff81b284e28f4774c4/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}}
- name: NPM install
run: |
echo ${{secrets.NPM_REGISTRY_AUTH}} >> ~/.npmrc
npm install
- name: run base ci ut and it
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci_with_docker_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ jobs:
- name: config s
run: |
sudo s config add --AccountID ${{secrets.ACCOUNTID}} --AccessKeyID ${{secrets.ACCESSKEYID}} --AccessKeySecret ${{secrets.ACCESSKEYSECRET}} -a quanxi -f
- name: Configure NPM
run: |
npm config set registry https://registry.npmjs.org
npm config set '//packages.aliyun.com/6455f7ff81b284e28f4774c4/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}}
- name: NPM install
run: |
echo ${{secrets.NPM_REGISTRY_AUTH}} >> ~/.npmrc
npm install
- name: NPM run build
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci_with_docker_macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ jobs:
- name: NPM install
run: |
npm install
- name: Configure NPM
run: |
npm config set registry https://registry.npmjs.org
npm config set '//packages.aliyun.com/6455f7ff81b284e28f4774c4/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}}
- name: NPM run build
run: |
echo ${{secrets.NPM_REGISTRY_AUTH}} >> ~/.npmrc
npm run build
- name: test python
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/registry-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
- name: s registry login
run: |
s registry login --token ${{ secrets.alibaba_registry_v3_publish_token }}
- name: Configure NPM
run: |
npm config set registry https://registry.npmjs.org
npm config set '//packages.aliyun.com/6455f7ff81b284e28f4774c4/npm/npm-registry/:_authToken' ${{secrets.NPM_TOKEN}}
- name: release prod
run: |
echo ${{secrets.NPM_REGISTRY_AUTH}} >> ~/.npmrc
make release-prod
3 changes: 2 additions & 1 deletion examples/s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ resources:
description: 'hello world by serverless devs'
runtime: "python3.10"
code: ./code
#artifact: acs:devs:cn-hangzhou:1431999136518149:artifacts/test-devs-artifact_cn-hangzhou
# artifact: test-devs-artifact_cn-hangzhou@1555622798284556248
artifact: acs:devs:cn-hangzhou:1431999136518149:artifacts/test-devs-artifact_cn-hangzhou
handler: index.handler
memorySize: 128
timeout: 40
14 changes: 11 additions & 3 deletions examples/s2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ resources:
handler: index.handler
memorySize: 128
timeout: 45
triggers:
- triggerName: httpTrigger
triggerType: http
triggerConfig:
methods:
- GET
- POST
authType: anonymous
disableURLInternet: false
customDomain:
domainName: auto
#domainName: "xiliu-test.devsapp.net"
protocol: HTTP
route:
methods:
- GET
- POST
# methods:
# - GET
path: /*
qualifier: LATEST
5 changes: 4 additions & 1 deletion src/subCommands/deploy/impl/custom_domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default class CustomDomain extends Base {
}
if (route.functionName === this.functionName && route.path === myRoute.path) {
found = true;
if (_.isEmpty(myRoute.methods)) {
routes[i].methods = [];
}
}
}
}
Expand Down Expand Up @@ -116,7 +119,7 @@ export default class CustomDomain extends Base {
}
deployInput.props.domainName = domainName;
const id = `${this.functionName}/${domainName}`;
logger.info(
logger.debug(
`deploy ${id}, deployInput props = \n${JSON.stringify(deployInput.props, null, 2)}`,
);
return await this.domainInstance.deploy(deployInput);
Expand Down
22 changes: 14 additions & 8 deletions src/subCommands/deploy/impl/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ export default class Service extends Base {
readTimeout: FC_CLIENT_READ_TIMEOUT,
connectTimeout: FC_CLIENT_CONNECT_TIMEOUT,
});
const { region } = this.inputs.props;
if (region.startsWith('cn-') && region !== 'cn-hongkong') {
config.endpoint = 'devs.cn-hangzhou.aliyuncs.com';
} else {
config.endpoint = 'devs.ap-southeast-1.aliyuncs.com';
}
config.endpoint = 'devs.cn-hangzhou.aliyuncs.com';
if (process.env.ARTIFACT_ENV === 'pre') {
config.endpoint = `devs-pre.cn-hangzhou.aliyuncs.com`;
}
Expand Down Expand Up @@ -127,7 +122,12 @@ export default class Service extends Base {
if (_.isEmpty(this.inputs.props.code) && this.inputs.props.artifact) {
await this.initDevsClient();
const { artifact } = this.inputs.props;
let artifactName = artifact.split('/')[1];
let artifactName = '';
if (artifact.split('/').length > 1) {
artifactName = artifact.split('/')[1].split('@')[0];
} else {
artifactName = artifact.split('@')[0];
}
const downPath: string = path.join(tmpDir, `${artifactName}_${accountID}_${uuidV4()}.zip`);
this.local.code = downPath;
if (_.includes(artifactName, '@')) {
Expand Down Expand Up @@ -490,7 +490,13 @@ nasConfig:
public async deployArtifact() {
const { runtime, functionName } = this.inputs.props;
if (!FC.isCustomContainerRuntime(runtime)) {
const artifactName = this.inputs.props.artifact.split('/')[1].split('@')[0];
const { artifact } = this.inputs.props;
let artifactName = '';
if (artifact.split('/').length > 1) {
artifactName = artifact.split('/')[1].split('@')[0];
} else {
artifactName = artifact.split('@')[0];
}
logger.info(`putArtifact ${artifactName}`);
await this.initDevsClient();
const { url } = await this.fcSdk.getFunctionCode(functionName, 'LATEST');
Expand Down
9 changes: 9 additions & 0 deletions src/subCommands/info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ export default class Info {
}
}
}
if (!_.isEmpty(customDomain)) {
if (info.url) {
info.url.custom_domain = customDomain.domainName;
} else {
info.url = {
custom_domain: customDomain.domainName,
};
}
}
return info;
}

Expand Down
2 changes: 1 addition & 1 deletion src/subCommands/plan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default class Plan {
}
planInput.props.domainName = domainName;
const id = `${this.functionName}/${domainName}`;
logger.info(`plan ${id}, planInput props = \n${JSON.stringify(planInput.props, null, 2)}`);
logger.debug(`plan ${id}, planInput props = \n${JSON.stringify(planInput.props, null, 2)}`);
return domainInstance.plan(planInput);
}
}

0 comments on commit b37b344

Please sign in to comment.