-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat(devops): Deploy to test environments via CI #3572
base: main
Are you sure you want to change the base?
Changes from all commits
6659b2f
2882078
37f74ee
7cef65c
e60d239
87364b9
fd1d776
f22e9ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ on: | |
options: | ||
- staging | ||
- beta | ||
- test_fe_1 | ||
- test_fe_2 | ||
- test_fe_3 | ||
- test_fe_4 | ||
- test_be_1 | ||
canister: | ||
required: true | ||
type: choice | ||
|
@@ -41,17 +46,6 @@ jobs: | |
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: Fail if branch is not main | ||
if: ${{ github.ref != 'refs/heads/main' }} | ||
run: | | ||
echo "This workflow can only be manually triggered with workflow_dispatch on the main branch" | ||
exit 1 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Determine Deployment Network | ||
run: | | ||
if [ "${{ github.event_name }}" == "push" ]; then | ||
|
@@ -62,25 +56,51 @@ jobs: | |
echo "CANISTER=${{ github.event.inputs.canister }}" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Check release policy | ||
run: | | ||
if [[ "$NETWORK" == "staging" ]] && [[ "${{ github.ref }}" != "refs/heads/main" ]] ; then | ||
echo "Only the main branch may be deployed to staging." | ||
exit 1 | ||
fi | ||
if [[ "$NETWORK" = test_fe_* ]] && [[ "$CANISTER" != "frontend" ]] ; then | ||
echo "Only a frontend may be deployed to test_fe_* networks" | ||
exit 1 | ||
fi | ||
if [[ "$NETWORK" = test_be_* ]] && [[ "$CANISTER" != "backend" ]] ; then | ||
echo "Only a backend may be deployed to test_be_* networks" | ||
exit 1 | ||
fi | ||
bitdivine marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe just a final ECHO if all checks passed for policy? as feedback for the dev There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Set Environment Variables Based on Network | ||
run: | | ||
if [ "$NETWORK" == "staging" ]; then | ||
if [[ "$NETWORK" == "staging" ]] || [[ "$NETWORK" = test_fe_* ]]; then | ||
echo "VITE_ETHERSCAN_API_KEY=${{ secrets.VITE_ETHERSCAN_API_KEY_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_INFURA_API_KEY=${{ secrets.VITE_INFURA_API_KEY_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_ALCHEMY_API_KEY=${{ secrets.VITE_ALCHEMY_API_KEY_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_WALLET_CONNECT_PROJECT_ID=${{ secrets.VITE_WALLET_CONNECT_PROJECT_ID_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_OISY_URL=${{ secrets.VITE_OISY_URL_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_AIRDROP=${{ secrets.VITE_AIRDROP_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_AIRDROP_COMPLETED=${{ secrets.VITE_AIRDROP_COMPLETED_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_COINGECKO_API_KEY=${{ secrets.VITE_COINGECKO_API_KEY_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_JUNO_SATELLITE_ID=${{ secrets.VITE_JUNO_SATELLITE_ID_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_JUNO_ORBITER_ID=${{ secrets.VITE_JUNO_ORBITER_ID_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_POUH_ENABLED=${{ secrets.VITE_POUH_ENABLED_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_AUTH_ALTERNATIVE_ORIGINS=${{ secrets.VITE_AUTH_ALTERNATIVE_ORIGINS_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_AUTH_DERIVATION_ORIGIN=${{ secrets.VITE_AUTH_DERIVATION_ORIGIN_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_BTC_TO_CKBTC_EXCHANGE_ENABLED=${{ secrets.VITE_BTC_TO_CKBTC_EXCHANGE_ENABLED_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_ONRAMPER_API_KEY_DEV=${{ secrets.VITE_ONRAMPER_API_KEY_DEV_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_ONRAMPER_API_KEY_PROD=${{ secrets.VITE_ONRAMPER_API_KEY_PROD_STAGING }}" >> $GITHUB_ENV | ||
if [[ "$NETWORK" == "staging" ]]; then | ||
echo "VITE_AUTH_ALTERNATIVE_ORIGINS=${{ secrets.VITE_AUTH_ALTERNATIVE_ORIGINS_STAGING }}" >> $GITHUB_ENV | ||
echo "VITE_OISY_URL=${{ secrets.VITE_OISY_URL_STAGING }}" >> $GITHUB_ENV | ||
else | ||
SUBDOMAIN="fe${NETWORK#test_fe_}" # E.g. test_fe_1 -> fe1 | ||
echo "VITE_AUTH_ALTERNATIVE_ORIGINS=${{ secrets.VITE_AUTH_ALTERNATIVE_ORIGINS_STAGING }}" | sed "s/staging/$SUBDOMAIN/g" >> $GITHUB_ENV | ||
echo "VITE_OISY_URL=${{ secrets.VITE_OISY_URL_STAGING }}" | sed "s/staging/$SUBDOMAIN/g" >> $GITHUB_ENV | ||
fi | ||
{ | ||
echo 'DFX_DEPLOY_KEY<<EOF' | ||
echo "${{ secrets.DFX_DEPLOY_KEY_STAGING }}" | ||
|
@@ -142,6 +162,7 @@ jobs: | |
dfx identity import --disable-encryption --force default "$key_pem" | ||
rm "$key_pem" | ||
dfx identity use default | ||
dfx identity get-principal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just a "good to have", right? it will print the principal so that we have more info, that's the idea? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. It is not enough for the code to be correct, we need to be able to verify that it is working correctly. It's hard to verify that the expected principal is being used when it's invisible. :-) Another point where we need better visibility for verification is the env vars, but that will be a bigger change so I didn't commit that. |
||
|
||
- name: Pre-build | ||
run: npm run build | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this include the check for beta?
for example, the check could pass if the network is beta, but the ref is not main, no? am i missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no rule that beta may have only head of main. Indeed, there is an explicit expectation that we should be able to put feature branches and release candidates (that may not be head of main) on beta.
I have proposed that we have a test environment that always holds the latest release candidate (so that would be the latest tag of the form 1.2.3-rc-4), which is effectively what beta has most of the time at the moment, however that has not been approved.