Deploy to ECS #464
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 ECS | |
on: | |
workflow_dispatch: | |
workflow_run: | |
# only runs additional steps if [ Create Ckan Base image ] was successful | |
workflows: [ Create Ckan Deployment image ] | |
types: [ completed ] | |
push: | |
branches: [ "deployment-workflow" ] | |
jobs: | |
deploy: | |
name: Deploy to AWS ECS | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Validate prerequisites | |
uses: ahmadnassri/action-workflow-run-wait@2aa3d9e1a12ecaaa9908e368eaf2123bb084323e | |
with: | |
timeout: 15000 # we stop trying to check altogether after 15 secs because there is no delay set up; this prevents hanging if the workflow is cancelled | |
# delay: 60000 # we try to check the status of the prerequisite workflows after 1 min | |
- name: Install Docker Compose CLI | |
uses: withlogicco/setup-compose-cli@631064dfb7d769983c89a86bd42e6bc7936101dc | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.ROLE_OIDC }} | |
aws-region: eu-west-2 | |
role-session-name: CKANDockerDeployment | |
- name: Set up ECS context | |
run: | | |
docker context create ecs ckanecs --from-env | |
docker context use ckanecs | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Update env file | |
run: | | |
sed -e 's|^AWS_ACCOUNT_ID=.*|AWS_ACCOUNT_ID=${{ secrets.AWS_ACCOUNT_ID }}|g | |
s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=${{ secrets.DB_P }}|g | |
s|^POSTGRES_HOST=.*|POSTGRES_HOST=${{ secrets.PG_HOST }}|g | |
s|^DATASTORE_READONLY_PASSWORD=.*|DATASTORE_READONLY_PASSWORD=${{ secrets.DT_P }}|g | |
s|^CKAN_SMTP_SERVER=.*|CKAN_SMTP_SERVER=${{ secrets.SMTP_SRV }}|g | |
s|^CKAN_SITE_URL=.*|CKAN_SITE_URL=${{ secrets.MDEP_URL }}|g | |
s|^CKAN_SMTP_USER=.*|CKAN_SMTP_USER=${{ secrets.SMTP_U }}|g | |
s|^CKAN_SMTP_PASSWORD=.*|CKAN_SMTP_PASSWORD=${{ secrets.SMTP_P }}|g | |
s|^CKANEXT__SAML2AUTH__IDP_METADATA__REMOTE_URL=.*|CKANEXT__SAML2AUTH__IDP_METADATA__REMOTE_URL=${{ secrets.SAML_REMOTE_URL }}|g | |
s|^CKANEXT__SAML2AUTH__ENTITY_ID=.*|CKANEXT__SAML2AUTH__ENTITY_ID=${{ secrets.SAML_IDENTITY_ID }}|g | |
s|^CKAN_SMDH__AWS_STORAGE_BUCKET_NAME=.*|CKAN_SMDH__AWS_STORAGE_BUCKET_NAME=${{ secrets.S3_NAME }}|g | |
s|^CKAN_SMDH__AWS_STORAGE_BUCKET_REGION=.*|CKAN_SMDH__AWS_STORAGE_BUCKET_REGION=${{ secrets.S3_REG }}|g | |
s|^CKANEXT__CLOUDSTORAGE__SYNC__QUEUE_NAME=.*|CKANEXT__CLOUDSTORAGE__SYNC__QUEUE_NAME=${{ secrets.CKANEXT__CLOUDSTORAGE__SYNC__QUEUE_NAME }}|g | |
s|^CKANEXT__CLOUDSTORAGE__SYNC__QUEUE_URL=.*|CKANEXT__CLOUDSTORAGE__SYNC__QUEUE_URL=${{ secrets.CKANEXT__CLOUDSTORAGE__SYNC__QUEUE_URL }}|g' \ | |
"contrib/docker-ckan/prod.env.template" > "contrib/docker-ckan/.env" | |
echo INTERNAL_REG=${{ secrets.CONTAINER_REGISTRY_URL }} >> contrib/docker-ckan/.env | |
echo "CERT_ARN=${{ secrets.CERT_ARN }}" >> contrib/docker-ckan/.env | |
- name: Prepare CF template | |
run: | | |
cd contrib/docker-ckan | |
./inject_sidecars.sh | |
- name: Deploy to ECS | |
run: | | |
cd contrib/docker-ckan | |
docker compose -f docker-compose.yml -f cf_temp.yml --env-file .env up |