|
|
@ -4,18 +4,15 @@ on: |
|
|
|
push: |
|
|
|
push: |
|
|
|
branches: |
|
|
|
branches: |
|
|
|
- main |
|
|
|
- main |
|
|
|
|
|
|
|
- gov_paas |
|
|
|
pull_request: |
|
|
|
pull_request: |
|
|
|
|
|
|
|
|
|
|
|
concurrency: 'Beta - Production' |
|
|
|
concurrency: 'sandbox' |
|
|
|
|
|
|
|
|
|
|
|
defaults: |
|
|
|
defaults: |
|
|
|
run: |
|
|
|
run: |
|
|
|
shell: bash |
|
|
|
shell: bash |
|
|
|
|
|
|
|
|
|
|
|
env: |
|
|
|
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
|
|
|
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jobs: |
|
|
|
jobs: |
|
|
|
|
|
|
|
|
|
|
|
test: |
|
|
|
test: |
|
|
@ -73,65 +70,32 @@ jobs: |
|
|
|
run: | |
|
|
|
run: | |
|
|
|
bundle exec rake |
|
|
|
bundle exec rake |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deploy: |
|
|
|
deploy: |
|
|
|
name: Deploy |
|
|
|
name: Deploy |
|
|
|
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest |
|
|
|
runs-on: ubuntu-latest |
|
|
|
environment: 'Beta - Production' |
|
|
|
|
|
|
|
if: github.ref == 'refs/heads/main' |
|
|
|
|
|
|
|
needs: |
|
|
|
|
|
|
|
- test |
|
|
|
|
|
|
|
timeout-minutes: 30 |
|
|
|
|
|
|
|
env: |
|
|
|
|
|
|
|
AWS_REGION: eu-west-2 |
|
|
|
|
|
|
|
ECR_REPOSITORY: container-repository |
|
|
|
|
|
|
|
ECS_SERVICE: app |
|
|
|
|
|
|
|
ECS_CLUSTER: ecs-cluster |
|
|
|
|
|
|
|
CONTAINER_NAME: app # set this to the name of the container in the containerDefinitions section of your task definition |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
steps: |
|
|
|
steps: |
|
|
|
- name: Checkout |
|
|
|
- name: Checkout code |
|
|
|
uses: actions/checkout@v2 |
|
|
|
uses: actions/checkout@v2 |
|
|
|
|
|
|
|
|
|
|
|
- name: Configure AWS credentials |
|
|
|
- name: Install cf client |
|
|
|
uses: aws-actions/configure-aws-credentials@v1 |
|
|
|
|
|
|
|
with: |
|
|
|
|
|
|
|
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} |
|
|
|
|
|
|
|
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} |
|
|
|
|
|
|
|
aws-region: ${{ env.AWS_REGION }} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Login to Amazon ECR |
|
|
|
|
|
|
|
id: login-ecr |
|
|
|
|
|
|
|
uses: aws-actions/amazon-ecr-login@v1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Build, tag, and push the image to Amazon ECR |
|
|
|
|
|
|
|
id: build-image |
|
|
|
|
|
|
|
env: |
|
|
|
env: |
|
|
|
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} |
|
|
|
CF_CLI_VERSION: 7.0.0-beta.30 |
|
|
|
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} |
|
|
|
|
|
|
|
IMAGE_TAG: ${{ github.sha }} |
|
|
|
|
|
|
|
run: | |
|
|
|
run: | |
|
|
|
# Build a docker container and push it to ECR |
|
|
|
curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=${CF_CLI_VERSION}" | tar -zx -C /tmp |
|
|
|
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . |
|
|
|
sudo cp /tmp/cf7 /usr/local/bin/cf7 |
|
|
|
echo "Pushing image to ECR..." |
|
|
|
- name: Deploy |
|
|
|
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
|
|
|
env: |
|
|
|
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" |
|
|
|
CF_USERNAME: ${{ secrets.CF_USERNAME }} |
|
|
|
|
|
|
|
CF_PASSWORD: ${{ secrets.CF_PASSWORD }} |
|
|
|
- name: Download task definition |
|
|
|
CF_API_ENDPOINT: ${{ secrets.CF_API_ENDPOINT }} |
|
|
|
|
|
|
|
CF_SPACE: ${{ secrets.CF_SPACE }} |
|
|
|
|
|
|
|
CF_ORG: ${{ secrets.CF_ORG }} |
|
|
|
run: | |
|
|
|
run: | |
|
|
|
aws ecs describe-task-definition --task-definition app --query taskDefinition > task-definition.json |
|
|
|
cf7 api $CF_API_ENDPOINT |
|
|
|
|
|
|
|
cf7 auth |
|
|
|
- name: Fill in the new image ID in the Amazon ECS task definition |
|
|
|
cf7 target -o $CF_ORG -s $CF_SPACE |
|
|
|
id: task-def |
|
|
|
cf7 push --strategy rolling |
|
|
|
uses: aws-actions/amazon-ecs-render-task-definition@v1 |
|
|
|
|
|
|
|
with: |
|
|
|
|
|
|
|
task-definition: task-definition.json |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|