Skip to content

Commit

Permalink
Create a dev server for the pr-deploy branch
Browse files Browse the repository at this point in the history
N.B. this uses the regular dev postgres database
  • Loading branch information
Bjwebb committed Aug 2, 2024
1 parent 820f482 commit a639324
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ jobs:
deploy_dev:
needs: [build]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
if: github.ref == 'refs/heads/pr-deploy'
env:
DOCKER_BUILDKIT: '1'
TAG: ${{ github.sha }}
STAGE: dev
STAGE: dev-tmp-pr-deploy
NAME: iati-website
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -106,6 +106,7 @@ jobs:
with:
azcliversion: 2.30.0
inlineScript: |
set -eux
az vm create \
--resource-group "${{ env.STAGE }}-${{ env.NAME }}-${{ env.NEW_COLOUR }}" \
--name "${{ env.STAGE }}-${{ env.NAME }}-${{ env.NEW_COLOUR }}" \
Expand All @@ -114,7 +115,7 @@ jobs:
--ssh-key-values ${{ secrets.DEV_PUB_KEYS }} && \
export NEW_IP=$(az vm list-ip-addresses --name "${{ env.STAGE }}-${{ env.NAME }}-${{ env.NEW_COLOUR }}" --resource-group "${{ env.STAGE }}-${{ env.NAME }}-${{ env.NEW_COLOUR }}" --query [].virtualMachine.network[].publicIpAddresses[][].ipAddress --output tsv) && \
echo "NEW_IP=$NEW_IP" >> $GITHUB_ENV && \
az postgres server firewall-rule update \
az postgres server firewall-rule create \
--resource-group "${{ secrets.DEV_PSQL_RESOURCE_GROUP }}" \
--server-name "${{ secrets.DEV_PSQL_NAME }}" \
--name "${{ env.STAGE }}-${{ env.NAME }}-${{ env.NEW_COLOUR }}" \
Expand Down Expand Up @@ -231,16 +232,16 @@ jobs:
echo "Failure"
exit 1
fi
- if: steps.new_has_succeeded.outcome == 'success'
name: "Update NGINX VM backend"
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null && \
ssh-add - <<< "${{ secrets.DEV_NGINX_KEY }}" && \
sed -i 's/XX.XX.XX.XX/'${{ env.NEW_IP }}'/g' config/nginx/website_dev.conf && \
scp -o StrictHostKeyChecking=no config/nginx/website_dev.conf azureuser@${{ secrets.DEV_NGINX_IP }}:/etc/nginx/conf.d/website.conf && \
ssh -o StrictHostKeyChecking=no azureuser@${{ secrets.DEV_NGINX_IP }} /home/azureuser/restart_nginx.sh
#- if: steps.new_has_succeeded.outcome == 'success'
# name: "Update NGINX VM backend"
# env:
# SSH_AUTH_SOCK: /tmp/ssh_agent.sock
# run: |
# ssh-agent -a $SSH_AUTH_SOCK > /dev/null && \
# ssh-add - <<< "${{ secrets.DEV_NGINX_KEY }}" && \
# sed -i 's/XX.XX.XX.XX/'${{ env.NEW_IP }}'/g' config/nginx/website_dev.conf && \
# scp -o StrictHostKeyChecking=no config/nginx/website_dev.conf azureuser@${{ secrets.DEV_NGINX_IP }}:/etc/nginx/conf.d/website.conf && \
# ssh -o StrictHostKeyChecking=no azureuser@${{ secrets.DEV_NGINX_IP }} /home/azureuser/restart_nginx.sh
- if: steps.new_has_succeeded.outcome == 'success'
name: "Delete previous VM resource group"
uses: "azure/[email protected]"
Expand Down

0 comments on commit a639324

Please sign in to comment.