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: Push the Docker image to AWS ECR Repo - STAGES/DEV | |
on: | |
push: | |
branches: | |
- stages/dev | |
workflow_dispatch: | |
inputs: | |
manual_ref: | |
type: string | |
description: The tag or hash that needs to be deployed | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
Build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.ROLE_ARN }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Get commit hash | |
id: get-commit-hash | |
run: echo "::set-output name=commit-hash::$(git rev-parse --short HEAD)" | |
- name: Build, tag, and push docker image to Amazon ECR | |
id: build-image | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: announcements-dev | |
IMAGE_TAG: ${{ steps.get-commit-hash.outputs.commit-hash }} | |
ALLOWED_HOSTS: ${{ secrets.ALLOWED_HOSTS }} | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
STATIC_URL: ${{ secrets.STATIC_URL }} | |
STATIC_ROOT: ${{ secrets.STATIC_ROOT }} | |
DJANGO_SUPERUSER_USERNAME: ${{ secrets.DJANGO_SUPERUSER_USERNAME }} | |
DJANGO_SUPERUSER_PASSWORD: ${{ secrets.DJANGO_SUPERUSER_PASSWORD }} | |
DJANGO_SUPERUSER_EMAIL: ${{ secrets.DJANGO_SUPERUSER_EMAIL }} | |
run: | | |
podman build \ | |
--build-arg DJANGO_SUPERUSER_USERNAME=${{ secrets.DJANGO_SUPERUSER_USERNAME }} \ | |
--build-arg DJANGO_SUPERUSER_PASSWORD=${{ secrets.DJANGO_SUPERUSER_PASSWORD }} \ | |
--build-arg DJANGO_SUPERUSER_EMAIL=${{ secrets.DJANGO_SUPERUSER_EMAIL }} \ | |
-f Containerfile -t announcements-dev . | |
podman tag announcements-dev:latest 897722699959.dkr.ecr.us-east-1.amazonaws.com/announcements-dev:latest | |
podman push 897722699959.dkr.ecr.us-east-1.amazonaws.com/announcements-dev | |