Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete env in right account #183

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
validation_api_apigateway_name: ${{ steps.parse_cdk_output.outputs.api_gateway_name }}
validation_api_apigateway_url: ${{ steps.parse_cdk_output.outputs.api_gateway_url }}\
validation_api_apigateway_key_id: ${{ steps.parse_cdk_output.outputs.api_gateway_key_id }}
test_env_name: ${{ steps.get_test_env_name.outputs.test_env_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -85,14 +86,30 @@ jobs:
run: |
echo "test_env_name=$(./.github/workflows/scripts/test_env_name.sh)" >> $GITHUB_OUTPUT || exit 1

- name: Select credentials
id: select_credentials
shell: bash
env:
TEST_ENVIRONMENT_NAME: ${{ steps.get_test_env_name.outputs.test_env_name }}
run: |
if [ "${TEST_ENVIRONMENT_NAME}" == 'main' ]; then
echo 'aws_account=${{secrets.AWS_ACCOUNT_PROD}}' >> ${GITHUB_OUTPUT}
echo 'aws_access_key=${{secrets.AWS_ACCESS_KEY_ID_PROD}}' >> ${GITHUB_OUTPUT}
echo 'aws_secret_access_key=${{secrets.AWS_SECRET_ACCESS_KEY_PROD}}' >> ${GITHUB_OUTPUT}
else
echo 'aws_account=${{secrets.AWS_ACCOUNT_DEV}}' >> ${GITHUB_OUTPUT}
echo 'aws_access_key=${{secrets.AWS_ACCESS_KEY_ID_DEV}}' >> ${GITHUB_OUTPUT}
echo 'aws_secret_access_key=${{secrets.AWS_SECRET_ACCESS_KEY_DEV}}' >> ${GITHUB_OUTPUT}
fi

- name: Deploy validation backend
shell: bash
working-directory: packages/otelbin-validation
env:
AWS_ACCESS_KEY_ID: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ACCESS_KEY_ID_PROD || secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ github.ref == 'refs/heads/main' && secrets.AWS_SECRET_ACCESS_KEY_PROD || secrets.AWS_SECRET_ACCESS_KEY_DEV }}
AWS_ACCESS_KEY_ID: ${{ steps.select_credentials.outputs.aws_access_key }}
AWS_SECRET_ACCESS_KEY: ${{ steps.select_credentials.outputs.aws_secret_access_key }}
AWS_DEFAULT_REGION: 'us-east-2'
CDK_DEPLOY_ACCOUNT: ${{ github.ref == 'refs/heads/main' && '462608073829' || '622203989445' }}
CDK_DEPLOY_ACCOUNT: ${{ steps.select_credentials.outputs.aws_account }}
CDK_DEPLOY_REGION: 'us-east-2'
GH_TOKEN: ${{ github.token }}
TEST_ENVIRONMENT_NAME: ${{ steps.get_test_env_name.outputs.test_env_name }}
Expand Down Expand Up @@ -143,12 +160,26 @@ jobs:
run: |
npm ci

- name: Select credentials
id: select_credentials
shell: bash
env:
TEST_ENVIRONMENT_NAME: ${{ needs.prep-itests.outputs.test_env_name }}
run: |
if [ "${TEST_ENVIRONMENT_NAME}" == 'main' ]; then
echo 'aws_access_key=${{secrets.AWS_ACCESS_KEY_ID_PROD}}' >> ${GITHUB_OUTPUT}
echo 'aws_secret_access_key=${{secrets.AWS_SECRET_ACCESS_KEY_PROD}}' >> ${GITHUB_OUTPUT}
else
echo 'aws_access_key=${{secrets.AWS_ACCESS_KEY_ID_DEV}}' >> ${GITHUB_OUTPUT}
echo 'aws_secret_access_key=${{secrets.AWS_SECRET_ACCESS_KEY_DEV}}' >> ${GITHUB_OUTPUT}
fi

- name: Retrieve API Key for Validation API and run tests
shell: bash
working-directory: packages/otelbin-validation
env:
AWS_ACCESS_KEY_ID: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ACCESS_KEY_ID_PROD || secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ github.ref == 'refs/heads/main' && secrets.AWS_SECRET_ACCESS_KEY_PROD || secrets.AWS_SECRET_ACCESS_KEY_DEV }}
AWS_ACCESS_KEY_ID: ${{ steps.select_credentials.outputs.aws_access_key }}
AWS_SECRET_ACCESS_KEY: ${{ steps.select_credentials.outputs.aws_secret_access_key }}
AWS_DEFAULT_REGION: 'us-east-2'
API_GATEWAY_NAME: ${{ needs.prep-itests.outputs.validation_api_apigateway_name }}
API_GATEWAY_URL: ${{ needs.prep-itests.outputs.validation_api_apigateway_url }}
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/clean-up-test-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,30 @@ jobs:
run: |
echo "test_env_name=$(./.github/workflows/scripts/test_env_name.sh)" >> $GITHUB_OUTPUT || exit 1

- name: Select credentials
id: select_credentials
shell: bash
env:
TEST_ENVIRONMENT_NAME: ${{ steps.get_test_env_name.outputs.test_env_name }}
run: |
if [ "${TEST_ENVIRONMENT_NAME}" == 'main' ]; then
echo 'aws_account=${{secrets.AWS_ACCOUNT_PROD}}' >> ${GITHUB_OUTPUT}
echo 'aws_access_key=${{secrets.AWS_ACCESS_KEY_ID_PROD}}' >> ${GITHUB_OUTPUT}
echo 'aws_secret_access_key=${{secrets.AWS_SECRET_ACCESS_KEY_PROD}}' >> ${GITHUB_OUTPUT}
else
echo 'aws_account=${{secrets.AWS_ACCOUNT_DEV}}' >> ${GITHUB_OUTPUT}
echo 'aws_access_key=${{secrets.AWS_ACCESS_KEY_ID_DEV}}' >> ${GITHUB_OUTPUT}
echo 'aws_secret_access_key=${{secrets.AWS_SECRET_ACCESS_KEY_DEV}}' >> ${GITHUB_OUTPUT}
fi

- name: Delete validation backend
shell: bash
working-directory: packages/otelbin-validation
env:
AWS_ACCESS_KEY_ID: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ACCESS_KEY_ID_PROD || secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ github.ref == 'refs/heads/main' && secrets.AWS_SECRET_ACCESS_KEY_PROD || secrets.AWS_SECRET_ACCESS_KEY_DEV }}
AWS_ACCESS_KEY_ID: ${{ steps.select_credentials.outputs.aws_access_key }}
AWS_SECRET_ACCESS_KEY: ${{ steps.select_credentials.outputs.aws_secret_access_key }}
AWS_DEFAULT_REGION: 'us-east-2'
CDK_DEPLOY_ACCOUNT: ${{ github.ref == 'refs/heads/main' && '462608073829' || '622203989445' }}
CDK_DEPLOY_ACCOUNT: ${{ steps.select_credentials.outputs.aws_account }}
CDK_DEPLOY_REGION: 'us-east-2'
GH_TOKEN: ${{ github.token }}
TEST_ENVIRONMENT_NAME: ${{ steps.get_test_env_name.outputs.test_env_name }}
Expand Down
Loading