Skip to content

Merge pull request #24 from 0xPolygon/nadim/fix-nginx #10

Merge pull request #24 from 0xPolygon/nadim/fix-nginx

Merge pull request #24 from 0xPolygon/nadim/fix-nginx #10

name: Docs Dev Deployment
on:
push:
branches: ['dev']
workflow_dispatch:
jobs:
deploy_staging:
name: Dev Deployment
permissions:
id-token: write
contents: write
environment: dev
runs-on: ubuntu-latest
env:
AWS_REGION: eu-west-1
ECR_REPOSITORY: docs-dev-ecr
ECS_SERVICE: docs-dev-ecs-service
ECS_CLUSTER: frontend-dev-ecs-cluster
ECS_TASK_DEFINITION: .github/assets/dev-taskdef.json
CONTAINER_NAME: docs-dev
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::605436358845:role/docs-dev-GithubActionsRole
role-session-name: GithubActionsSession
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Use Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: pip Install
run: pip install -r requirements.txt --no-cache-dir
- name: Build mkdocs
run: mkdocs build
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f .github/assets/Dockerfile.nginx .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true