-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (68 loc) · 2.37 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
on:
workflow_call:
inputs:
env:
required: true
type: string
version-name:
required: true
type: string
description: descriptive id of what's deployed (e.g. release name or pr number). doesn't have to be unique, the git hash is appended later
secrets:
AWS_ROLE_ARN:
required: true
DOCKER_REPO:
required: true
SLACK_WEBHOOK:
required: true
jobs:
deploy:
name: Deploy to ${{ inputs.env }}
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment: ${{ inputs.env }}
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get versions
id: calc-version
run: |
docker_repo="${{ secrets.DOCKER_REPO }}"
git_hash="$(git rev-parse --short HEAD)"
version_id="${{ inputs.version-name }}-$git_hash"
git_hash_tag="$docker_repo:git-$git_hash"
latest_env_tag="$docker_repo:latest-${{ inputs.env }}"
version_tag="$docker_repo:$version_id"
echo "version-id=$version_id" | tee -a $GITHUB_OUTPUT
echo "deploy-tag=$version_tag" | tee -a $GITHUB_OUTPUT
printf "tag-list=%s,%s,%s\n" "$git_hash_tag" "$latest_env_tag" "$version_tag" | tee -a $GITHUB_OUTPUT
- uses: aws-actions/amazon-ecr-login@v2
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha
build-args: |
RELEASE=${{ steps.calc-version.outputs.version-id }}
tags: ${{ steps.calc-version.outputs.tag-list }}
push: true
- uses: mbta/actions/deploy-ecs@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
ecs-cluster: orbit
ecs-service: orbit-${{ inputs.env }}
docker-tag: ${{ steps.calc-version.outputs.deploy-tag }}
- uses: mbta/actions/notify-slack-deploy@v2
if: ${{ !cancelled() }}
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
job-status: ${{ job.status }}
custom-message: Deployed ${{ steps.calc-version.outputs.version-id }} to ${{ inputs.env }}