Browse Source

Production WIP

cldc-2563-aws-production-pipeline-backup
Sam Seed 1 year ago
parent
commit
f7632aaa1b
  1. 33
      .github/workflows/aws_deploy.yml
  2. 12
      .github/workflows/production_pipeline.yml

33
.github/workflows/aws_deploy.yml

@ -21,9 +21,11 @@ env:
app_repo_role: arn:aws:iam::815624722760:role/core-application-repo
aws_region: eu-west-2
repository: core
REPO_URL: communitiesuk/submit-social-housing-lettings-and-sales-data
jobs:
push_docker_image:
if: inputs.environment != 'production'
name: Push docker image to AWS
runs-on: ubuntu-latest
permissions:
@ -59,6 +61,9 @@ jobs:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs: push_docker_image
if: |
always() &&
(needs.push_docker_image.result == 'success' || needs.push_docker_image.result == 'skipped')
steps:
- name: Configure AWS credentials
@ -75,13 +80,37 @@ jobs:
- name: Get timestamp
id: timestamp
run: echo "timestamp=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
if: inputs.environment != 'production'
run: |
echo "::set-output name=timestamp::$(echo "timestamp=$(date +%Y%m%d%H%M%S)")"
- name: Get latest release with tag
id: latestrelease
if: inputs.environment == 'production'
run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')"
- name: Confirm release tag
if: inputs.environment == 'production'
run: |
echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag
uses: actions/checkout@v3
if: inputs.environment == 'production'
with:
ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Construct environment-dependent tag
id: tag
run: |
echo "::set-output name=tag::$(if [[ ${{ inputs.environment == 'production' }} ]] then ${{ steps.latestrelease.outputs.releasetag }} else ${{ steps.timestamp.outputs.timestamp }} fi)"
- name: Add environment tag to existing image
env:
registry: ${{ steps.ecr-login.outputs.registry }}
commit_tag: ${{ github.sha }}
readable_tag: ${{ inputs.environment }}-${{ env.timestamp }}
readable_tag: ${{ inputs.environment }}-${{ steps.tag.outputs.tag }}
run: |
manifest=$(aws ecr batch-get-image --repository-name $repository --image-ids imageTag=$commit_tag --output text --query images[].imageManifest)
aws ecr put-image --repository-name $repository --image-tag $readable_tag --image-manifest "$manifest"

12
.github/workflows/production_pipeline.yml

@ -257,3 +257,15 @@ jobs:
cf set-env $APP_NAME CSV_DOWNLOAD_PAAS_INSTANCE $CSV_DOWNLOAD_PAAS_INSTANCE
cf set-env $APP_NAME SENTRY_DSN $SENTRY_DSN
cf push $APP_NAME --strategy rolling
# aws_deploy:
# name: AWS Deploy
# if: github.ref == 'refs/heads/main'
# needs: [lint, test, feature_test, audit]
# uses: ./.github/workflows/aws_deploy.yml
# with:
# aws_account_id: 977287343304
# aws_resource_prefix: core-prod
# environment: production
# permissions:
# id-token: write

Loading…
Cancel
Save