deploy server #1
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 Server | |
on: | |
# workflow_call: | |
# pull_request: | |
# branches: | |
# - main | |
push: | |
# branches: | |
# - main | |
# paths: | |
# - 'server/**' | |
defaults: | |
run: | |
working-directory: ./server | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎 Checkout | |
uses: actions/checkout@v2 | |
- 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: Install AWS Lightsail Client | |
run: | | |
curl "https://s3.us-west-2.amazonaws.com/lightsailctl/latest/linux-amd64/lightsailctl" -o "lightsailctl" | |
sudo mv "lightsailctl" "/usr/local/bin/lightsailctl" | |
sudo chmod +x /usr/local/bin/lightsailctl | |
- name: Build and push image to Lightsail | |
id: build-image | |
run: | | |
docker build --build-arg API_DB_URL="${{ secrets.API_DB_URL }}" -t f1-fantasy-league:latest . | |
aws lightsail push-container-image --region us-east-1 --service-name f1-fantasy-league --label f1-fantasy-league-api --image f1-fantasy-league:latest | |
- name: Deploy Service | |
run: | | |
aws lightsail get-container-images --service-name f1-fantasy-league | jq --raw-output ".containerImages[0].image" > image.txt | |
jq --arg image $(cat image.txt) '.containers.app.image = $image' container.template.json > container.json | |
aws lightsail create-container-service-deployment --service-name f1-fantasy-league --cli-input-json file://$(pwd)/container.json |