-
Notifications
You must be signed in to change notification settings - Fork 455
49 lines (47 loc) · 1.88 KB
/
docker.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
name: docker
on:
push:
branches: main
paths-ignore:
- "**.md"
- "docs/**"
- "website/**"
- "cdk.tf/**"
- "tools/update-github-project-board/**"
jobs:
build-docker-image:
if: github.repository == 'hashicorp/terraform-cdk'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c
- name: Cache Docker layers
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('/Dockerfile', '.terraform.versions.json') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: tf-versions
run: |
DEFAULT_TERRAFORM_VERSION=$(cat .terraform.versions.json | jq -r '.default')
AVAILABLE_TERRAFORM_VERSIONS=$(cat .terraform.versions.json | jq -r '.available | join(" ")')
echo "default=$DEFAULT_TERRAFORM_VERSION" >> $GITHUB_OUTPUT
echo "available=$AVAILABLE_TERRAFORM_VERSIONS" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
pull: true
push: true
tags: hashicorp/jsii-terraform:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
DEFAULT_TERRAFORM_VERSION=${{ steps.tf-versions.outputs.default }}
AVAILABLE_TERRAFORM_VERSIONS=${{ steps.tf-versions.outputs.available }}