如何转换CircleCI yml文件脚本或如何将CircleCI构建迁移到Azure DevOps管道?我在CircleCI中有一个有效的config.yml文件,我想在Azure DevOps中运行该yml文件。
config.yml:
gcp_runtime: &gcp_runtime
docker:
- image: boiyaa/google-cloud-sdk-nodejs
setup-production_credentials: &setup-production_credentials
run:
name: Setup credentials to act on behalf of circle service account
command: |
echo ${GCLOUD_SERVICE_KEY_PRODUCTION} > ${HOME}/gcp-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcp-key.json
gcloud container clusters get-credentials ${GCLOUD_PROJECT_CLUSTER_ID_PRODUCTION} \
--zone ${GCLOUD_PROJECT_CLUSTER_ZONE_PRODUCTION} \
--project ${GCLOUD_PROJECT_ID_PRODUCTION}
setup-staging_credentials: &setup-staging_credentials
run:
name: Setup credentials to act on behalf of circle service account
command: |
echo ${GCLOUD_SERVICE_KEY_STAGING} > ${HOME}/gcp-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcp-key.json
gcloud container clusters get-credentials ${GCLOUD_PROJECT_CLUSTER_ID_STAGING} \
--zone ${GCLOUD_PROJECT_CLUSTER_ZONE_STAGING} \
--project ${GCLOUD_PROJECT_ID_STAGING}
setup-production-env: &setup-production-env
run:
name: Setup env for production
command: |
rm -f .env
echo "REACT_APP_API_URL=${REACT_APP_API_URL_PRODUCTION}" >> .env
echo "REACT_APP_SOCIAL_API_URL=${REACT_APP_SOCIAL_API_URL_PRODUCTION}" >> .env
echo "REACT_APP_WEB_URL=${REACT_APP_WEB_URL_PRODUCTION}" >> .env
echo "REACT_APP_AUTH0_DOMAIN=${REACT_APP_AUTH0_DOMAIN_PRODUCTION}" >> .env
echo "REACT_APP_AUTH0_CLIENT_ID=${REACT_APP_AUTH0_CLIENT_ID_PRODUCTION}" >> .env
echo "REACT_APP_PUSHER_KEY=${REACT_APP_PUSHER_KEY_PRODUCTION}" >> .env
echo "REACT_APP_PUSHER_CLUSTER=${REACT_APP_PUSHER_CLUSTER_PRODUCTION}" >> .env
echo "REACT_APP_VALID_DOMAIN=${REACT_APP_VALID_DOMAIN_PRODUCTION}" >> .env
setup-staging-env: &setup-staging-env
run:
name: Setup env for staging
command: |
rm -f .env
echo "REACT_APP_API_URL=${REACT_APP_API_URL_STAGING}" >> .env
echo "REACT_APP_SOCIAL_API_URL=${REACT_APP_SOCIAL_API_URL_STAGING}" >> .env
echo "REACT_APP_WEB_URL=${REACT_APP_WEB_URL_STAGING}" >> .env
echo "REACT_APP_AUTH0_DOMAIN=${REACT_APP_AUTH0_DOMAIN_STAGING}" >> .env
echo "REACT_APP_AUTH0_CLIENT_ID=${REACT_APP_AUTH0_CLIENT_ID_STAGING}" >> .env
echo "REACT_APP_PUSHER_KEY=${REACT_APP_PUSHER_KEY_STAGING}" >> .env
echo "REACT_APP_PUSHER_CLUSTER=${REACT_APP_PUSHER_CLUSTER_STAGING}" >> .env
echo "REACT_APP_VALID_DOMAIN=${REACT_APP_VALID_DOMAIN_STAGING}" >> .env
build_docker_images: &build_docker_images
run:
name: build and cache all docker images first and fail before deploying
command: |
true || docker build --build-arg CIRCLE_BUILD_NUM=${CIRCLE_BUILD_NUM:-0} -f ./Dockerfile -t web .
deploy_script_production: &deploy_script_production
run:
name: Deploy the application to prod
command: bash ./deploy/deploy-all.sh prod
deploy_script_staging: &deploy_script_staging
run:
name: Deploy the application to staging
command: bash ./deploy/deploy-all.sh staging
deploy-production: &deploy-production
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- *build_docker_images
- *setup-production-env
- *setup-production_credentials
- *deploy_script_production
deploy-staging: &deploy-staging
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- *build_docker_images
- *setup-staging-env
- *setup-staging_credentials
- *deploy_script_staging
version: 2
jobs:
deploy_to_production:
<<: *gcp_runtime
environment:
ENVIRONMENT: production
SKIP_BASE: "true"
<<: *deploy-production
deploy_to_staging:
<<: *gcp_runtime
environment:
ENVIRONMENT: staging
SKIP_BASE: "true"
<<: *deploy-staging
workflows:
version: 2
deploy_to_production:
jobs:
- deploy_to_production:
filters:
branches:
only: production
deploy_to_staging:
jobs:
- deploy_to_staging:
filters:
branches:
only: staging