Merge pull request #118 from wooyeon0626/feature/join #226
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: Build and deploy Docker app to Lightsail | |
on: | |
push: | |
branches: | |
- [ develop ] | |
env: | |
AWS_REGION: ap-northeast-2 | |
AWS_LIGHTSAIL_SERVICE_NAME: wooyeon | |
jobs: | |
deploy: | |
name: Build and deploy | |
runs-on: ubuntu-latest | |
# defaults: | |
# run: | |
# working-directory: ligthsail-example | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Utilities | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq unzip | |
- name: Install AWS Client | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install || true | |
aws --version | |
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: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_LIGHTSAIL_ACCESSKEY }} | |
aws-secret-access-key: ${{ secrets.AWS_LIGHTSAIL_SECRETKEY }} | |
- name: Build Docker Image | |
run: DOCKER_BUILDKIT=1 docker build -t ${{ env.AWS_LIGHTSAIL_SERVICE_NAME }}:release . | |
- name: Push and Deploy | |
run: | | |
service_name=${{ env.AWS_LIGHTSAIL_SERVICE_NAME }} | |
aws lightsail push-container-image \ | |
--region ${{ env.AWS_REGION }} \ | |
--service-name ${service_name} \ | |
--label ${service_name} \ | |
--image ${service_name}:release | |
aws lightsail get-container-images --service-name ${service_name} | 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 ${service_name} --cli-input-json file://$(pwd)/container.json |