Docker Push #69
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: Docker Push | |
on: | |
workflow_dispatch: | |
env: | |
node_version: "20.10.0" | |
python_version: "3.10" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup AWS ECR Details | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.NEXT_PUBLIC_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{secrets.NEXT_PUBLIC_AWS_REGION}} | |
- name: Login to Amazon ECR | |
id: login-pf-aws-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
# - uses: actions/download-artifact@master | |
# with: | |
# name: env-file | |
- name: create .env.local file | |
run: | | |
touch .env.local | |
echo NEXT_PUBLIC_AWS_REGION=${{ secrets.NEXT_PUBLIC_AWS_REGION }} >> .env.local | |
echo NEXT_PUBLIC_AWS_COGNITO_USERPOOL_ID=${{ secrets.NEXT_PUBLIC_AWS_COGNITO_USERPOOL_ID }} >> .env.local | |
echo NEXT_PUBLIC_AWS_COGNITO_USERPOOL_CLIENT_ID=${{ secrets.NEXT_PUBLIC_AWS_COGNITO_USERPOOL_CLIENT_ID }} >> .env.local | |
echo NEXT_PUBLIC_AWS_ACCESS_KEY_ID=${{ secrets.NEXT_PUBLIC_AWS_ACCESS_KEY_ID }} >> .env.local | |
echo NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY=${{ secrets.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY }} >> .env.local | |
echo NEXT_PUBLIC_ENV_NAME=${{ secrets.NEXT_PUBLIC_ENV_NAME }} >> .env.local | |
echo NEXT_PUBLIC_COGNITO_OPENID_CONF_URI=${{ secrets.NEXT_PUBLIC_COGNITO_OPENID_CONF_URI }} >> .env.local | |
echo NEXT_PUBLIC_BACKEND_BASE_URL=${{ secrets.NEXT_PUBLIC_BACKEND_BASE_URL }} >> .env.local | |
echo NEXT_PUBLIC_DOMAIN_NAME=${{ secrets.NEXT_PUBLIC_DOMAIN_NAME }} >> .env.local | |
echo NEXT_PUBLIC_ADMIN_EMAIL=${{ secrets.NEXT_PUBLIC_ADMIN_EMAIL }} >> .env.local | |
echo NEXT_PUBLIC_AWS_SAGEMAKER_DOMAIN_ID=${{ secrets.NEXT_PUBLIC_AWS_SAGEMAKER_DOMAIN_ID }} >> .env.local | |
echo NEXT_PUBLIC_AWS_SAGEMAKER_USER_NAME=${{ secrets.NEXT_PUBLIC_AWS_SAGEMAKER_USER_NAME }} >> .env.local | |
- name: Build and push the tagged docker image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }} | |
ECR_REPOSITORY: ${{ secrets.ECR_REPO }} | |
IMAGE_TAG: latest | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
ecs-update: | |
runs-on: ubuntu-latest | |
needs: | |
- docker | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.NEXT_PUBLIC_AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: eu-west-2 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: ${{env.python_version}} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install awscli | |
- name: Start ECS App service | |
run: | | |
aws ecs update-service --cluster hc-platform-main-app-cluster --service nextjs-app-service --force-new-deployment |