|
|
@ -12,6 +12,9 @@ on: |
|
|
|
environment: |
|
|
|
environment: |
|
|
|
required: true |
|
|
|
required: true |
|
|
|
type: string |
|
|
|
type: string |
|
|
|
|
|
|
|
release_tag: |
|
|
|
|
|
|
|
required: false |
|
|
|
|
|
|
|
type: string |
|
|
|
|
|
|
|
|
|
|
|
concurrency: |
|
|
|
concurrency: |
|
|
|
group: deploy-${{ inputs.environment }} |
|
|
|
group: deploy-${{ inputs.environment }} |
|
|
@ -80,40 +83,30 @@ jobs: |
|
|
|
|
|
|
|
|
|
|
|
- name: Get timestamp |
|
|
|
- name: Get timestamp |
|
|
|
id: timestamp |
|
|
|
id: timestamp |
|
|
|
run: echo "timestamp=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV |
|
|
|
run: echo "timestamp=$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT |
|
|
|
|
|
|
|
|
|
|
|
- name: Get latest release with tag |
|
|
|
|
|
|
|
id: latestrelease |
|
|
|
|
|
|
|
if: inputs.environment == 'production' |
|
|
|
|
|
|
|
run: | |
|
|
|
|
|
|
|
echo "releasetag=$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" >> $GITHUB_OUTPUT |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Confirm release tag |
|
|
|
|
|
|
|
if: inputs.environment == 'production' |
|
|
|
|
|
|
|
run: | |
|
|
|
|
|
|
|
echo ${{ steps.latestrelease.outputs.releasetag }} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Checkout tag |
|
|
|
- name: Checkout release tag |
|
|
|
uses: actions/checkout@v3 |
|
|
|
uses: actions/checkout@v3 |
|
|
|
if: inputs.environment == 'production' |
|
|
|
if: inputs.environment == 'production' |
|
|
|
with: |
|
|
|
with: |
|
|
|
ref: ${{ steps.latestrelease.outputs.releasetag }} |
|
|
|
ref: ${{ inputs.release_tag }} |
|
|
|
|
|
|
|
|
|
|
|
- name: Get tags |
|
|
|
- name: Get tags |
|
|
|
id: tags |
|
|
|
id: tags |
|
|
|
run: | |
|
|
|
run: | |
|
|
|
echo "commit-tag=$(if [[ ${{ inputs.environment == 'production' }} ]]; then echo $(git log -1 '--format=format:%H'); else echo ${{ github.sha }}; fi)" >> $GITHUB_OUTPUT |
|
|
|
echo "commit-tag=$(if [[ ${{ inputs.environment == 'production' }} ]]; then echo $(git log -1 '--format=format:%H'); else echo ${{ github.sha }}; fi)" >> $GITHUB_OUTPUT |
|
|
|
echo "additional-tag=$(if [[ ${{ inputs.environment == 'production' }} ]]; then echo ${{ steps.latestrelease.outputs.releasetag }}; else echo ${{ env.timestamp }}; fi)" >> $GITHUB_OUTPUT |
|
|
|
echo "additional-tag=$(if [[ ${{ inputs.environment == 'production' }} ]]; then echo ${{ inputs.release_tag }}; else echo ${{ steps.timestamp.outputs.timestamp }}; fi)" >> $GITHUB_OUTPUT |
|
|
|
|
|
|
|
|
|
|
|
- name: Add environment tag to existing image |
|
|
|
- name: Add environment tag to existing image |
|
|
|
|
|
|
|
id: update-image-tags |
|
|
|
env: |
|
|
|
env: |
|
|
|
registry: ${{ steps.ecr-login.outputs.registry }} |
|
|
|
registry: ${{ steps.ecr-login.outputs.registry }} |
|
|
|
commit_tag: ${{ steps.tags.outputs.commit-tag }} |
|
|
|
commit_tag: ${{ steps.tags.outputs.commit-tag }} |
|
|
|
readable_tag: ${{ inputs.environment }}-${{ steps.tags.outputs.additional-tag }}-${{ env.timestamp }} |
|
|
|
readable_tag: ${{ inputs.environment }}-${{ steps.tags.outputs.additional-tag }}-${{ steps.timestamp.outputs.timestamp }} |
|
|
|
run: | |
|
|
|
run: | |
|
|
|
manifest=$(aws ecr batch-get-image --repository-name $repository --image-ids imageTag=$commit_tag --output text --query images[].imageManifest) |
|
|
|
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" |
|
|
|
aws ecr put-image --repository-name $repository --image-tag $readable_tag --image-manifest "$manifest" |
|
|
|
echo "image=$registry/$repository:$readable_tag" >> $GITHUB_ENV |
|
|
|
echo "image=$registry/$repository:$readable_tag" >> $GITHUB_OUTPUT |
|
|
|
|
|
|
|
|
|
|
|
- name: Configure AWS credentials for environment |
|
|
|
- name: Configure AWS credentials for environment |
|
|
|
uses: aws-actions/configure-aws-credentials@v3 |
|
|
|
uses: aws-actions/configure-aws-credentials@v3 |
|
|
@ -134,7 +127,7 @@ jobs: |
|
|
|
with: |
|
|
|
with: |
|
|
|
task-definition: ad-hoc-task-definition.json |
|
|
|
task-definition: ad-hoc-task-definition.json |
|
|
|
container-name: app |
|
|
|
container-name: app |
|
|
|
image: ${{ env.image }} |
|
|
|
image: ${{ steps.update-image-tags.outputs.image }} |
|
|
|
|
|
|
|
|
|
|
|
- name: Update ad hoc task definition |
|
|
|
- name: Update ad hoc task definition |
|
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 |
|
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 |
|
|
@ -169,7 +162,7 @@ jobs: |
|
|
|
with: |
|
|
|
with: |
|
|
|
task-definition: app-task-definition.json |
|
|
|
task-definition: app-task-definition.json |
|
|
|
container-name: app |
|
|
|
container-name: app |
|
|
|
image: ${{ env.image }} |
|
|
|
image: ${{ steps.update-image-tags.outputs.image }} |
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy updated application |
|
|
|
- name: Deploy updated application |
|
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 |
|
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 |
|
|
@ -191,7 +184,7 @@ jobs: |
|
|
|
with: |
|
|
|
with: |
|
|
|
task-definition: sidekiq-task-definition.json |
|
|
|
task-definition: sidekiq-task-definition.json |
|
|
|
container-name: sidekiq |
|
|
|
container-name: sidekiq |
|
|
|
image: ${{ env.image }} |
|
|
|
image: ${{ steps.update-image-tags.outputs.image }} |
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy updated sidekiq |
|
|
|
- name: Deploy updated sidekiq |
|
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 |
|
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 |
|
|
|