Merge pull request #57 from se-gam/dev #11
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 Amazon Elastic Beanstalk (Prod 2025) | |
on: | |
push: | |
branches: | |
- prod-2025 | |
permissions: | |
contents: read | |
jobs: | |
CD: | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.PROD_2025_AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.PROD_2025_AWS_SECRET_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Create .env file | |
run: | | |
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$SECRETS_CONTEXT" > .prod2025.env | |
env: | |
SECRETS_CONTEXT: ${{ toJson(secrets) }} | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: segam2025 | |
IMAGE_TAG: latest | |
run: | | |
# Build a docker container and | |
# push it to ECR | |
docker build -f prod2025.dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
- name: Deploy to EB | |
uses: einaregilsson/beanstalk-deploy@v14 | |
with: | |
aws_access_key: ${{ secrets.PROD_2025_AWS_ACCESS_KEY }} | |
aws_secret_key: ${{ secrets.PROD_2025_AWS_SECRET_KEY }} | |
application_name: segam-2025 | |
environment_name: Segam-2025-env | |
region: ap-northeast-2 | |
version_label: ${{github.SHA}} | |
deployment_package: Prod2025-Dockerrun.aws.json | |
use_existing_version_if_available: true | |
wait_for_environment_recovery: 180 |