Deploy to AWS #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to AWS | |
on: | |
push: | |
branches: [ deployment-aws-production, deployment-aws-staging ] | |
workflow_dispatch: | |
inputs: | |
target: | |
description: 'Target' | |
required: true | |
default: 'production' | |
type: choice | |
options: | |
- 'staging' | |
- 'production' | |
jobs: | |
deploy: | |
name: Deploy to AWS | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Setup Dart SDK | |
uses: dart-lang/[email protected] | |
with: | |
sdk: 3.1 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Create passwords file | |
working-directory: tracking_server | |
shell: bash | |
env: | |
SERVERPOD_PASSWORDS: ${{ secrets.SERVERPOD_PASSWORDS }} | |
run: | | |
pwd | |
echo "$SERVERPOD_PASSWORDS" > config/passwords.yaml | |
ls config/ | |
- name: Get Dart packages | |
working-directory: tracking_server | |
run: dart pub get | |
- name: Compile server | |
working-directory: tracking_server | |
run: dart compile kernel bin/main.dart | |
- name: Create CodeDeploy Deployment | |
id: deploy | |
env: | |
PROJECT_NAME: tracking | |
AWS_NAME: tracking | |
DEPLOYMENT_BUCKET: tracking-deployment-5471302 | |
TARGET: ${{ github.event.inputs.target }} | |
run: | | |
# Deploy server to AWS | |
TARGET="${TARGET:=${GITHUB_REF##*-}}" | |
echo "Deploying to target: $TARGET" | |
mkdir -p vendor | |
cp "${PROJECT_NAME}_server/deploy/aws/scripts/appspec.yml" appspec.yml | |
zip -r deployment.zip . | |
aws s3 cp deployment.zip "s3://${DEPLOYMENT_BUCKET}/deployment.zip" | |
aws deploy create-deployment \ | |
--application-name "${AWS_NAME}-app" \ | |
--deployment-group-name "${AWS_NAME}-${TARGET}-group" \ | |
--deployment-config-name CodeDeployDefault.OneAtATime \ | |
--s3-location "bucket=${DEPLOYMENT_BUCKET},key=deployment.zip,bundleType=zip" |