-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (76 loc) · 2.3 KB
/
ci.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
name: CI
on:
push:
pull_request:
jobs:
validate:
name: terraform lint and validate
runs-on: ubuntu-22.04
timeout-minutes: 4
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check tag updated if this is a tag
run: |
./ci/check_tag.sh
- name: Install terraform
uses: hashicorp/setup-terraform@v2
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Validate
run: |
cd ecs-cluster
terraform init -backend=false
terraform validate
- name: pre-commit
uses: pre-commit/[email protected]
container-build:
runs-on: ubuntu-22.04
needs:
- validate
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
# Set this to `main` to rebuild container on every push to main
# instead of just tags
PUBLISH_BRANCH: ""
PLATFORMS: linux/amd64,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
if: >
github.event_name == 'push' &&
(github.ref == format('refs/heads/{0}', env.PUBLISH_BRANCH) ||
startsWith(github.ref, 'refs/tags/'))
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/metadata-action
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# https://github.com/docker/build-push-action
- name: Build and push
uses: docker/build-push-action@v3
with:
context: ./container
platforms: ${{ env.PLATFORMS }}
push: >
${{ github.ref == format('refs/heads/{0}', env.PUBLISH_BRANCH) ||
startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}