-
Notifications
You must be signed in to change notification settings - Fork 15
135 lines (124 loc) · 4.67 KB
/
docker.yml
File metadata and controls
135 lines (124 loc) · 4.67 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Reusable workflow for building docker containers
---
name: Build docker container
on:
workflow_call:
inputs:
name:
description: 'name of the container image'
required: true
type: string
context:
description: 'build context'
required: false
type: string
default: "."
build-args:
description: 'build args'
required: false
type: string
default: ""
tag-suffix:
description: 'container tag suffix'
required: false
type: string
default: ""
run-disk-space-cleanup:
description: 'Boolean flag whether clean script is required on the runner. Should set it to true for large images'
required: false
type: boolean
default: false
registry:
description: 'container registry'
required: false
type: string
default: 'quay.io'
registry-org-name:
description: 'container registry org name'
required: false
type: string
default: 'labdao'
deploy-environment:
description: 'environment to deploy into'
required: false
type: string
jobs:
container-build-and-push:
runs-on: ubuntu-latest
steps:
- name: Inputs
id: docker-build-and-push-inputs
run: |
echo "## INPUTS" >> $GITHUB_STEP_SUMMARY
echo "| INPUT NAME | INPUT VALUE |" >> $GITHUB_STEP_SUMMARY
echo "|---|---|" >> $GITHUB_STEP_SUMMARY
echo "| name | ${{ inputs.name }} |" >> $GITHUB_STEP_SUMMARY
echo "| context | ${{ inputs.context }} |" >> $GITHUB_STEP_SUMMARY
echo "| build-args | ${{ inputs.build-args }} |" >> $GITHUB_STEP_SUMMARY
echo "| tag-suffix | ${{ inputs.tag-suffix }} |" >> $GITHUB_STEP_SUMMARY
echo "| run-disk-space-cleanup | ${{ inputs.run-disk-space-cleanup }} |" >> $GITHUB_STEP_SUMMARY
echo "| registry | ${{ inputs.registry }} |" >> $GITHUB_STEP_SUMMARY
echo "| registry-org-name | ${{ inputs.registry-org-name }} |" >> $GITHUB_STEP_SUMMARY
- name: Checkout
uses: actions/checkout@v4
- name: Free Disk Space
run: .github/scripts/free-disk-space.sh
if: ${{ inputs.run-disk-space-cleanup }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.registry }}/${{ inputs.registry-org-name }}/${{inputs.name}}
tags: |
type=ref,suffix=${{ inputs.tag-suffix }},event=branch
type=ref,suffix=${{ inputs.tag-suffix }},event=pr
type=ref,suffix=${{ inputs.tag-suffix }},event=tag
type=sha,suffix=${{ inputs.tag-suffix }}
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.LABDAO_QUAY_USERNAME }}
password: ${{ secrets.LABDAO_QUAY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
id: build-and-push
with:
build-args: |
${{ inputs.build-args }}
NEXT_PUBLIC_PRIVY_APP_ID=${{ secrets.NEXT_PUBLIC_PRIVY_APP_ID }}
push: true
tags: ${{ steps.meta.outputs.tags }}
context: ${{ inputs.context }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image output
id: docker-build-and-push-outputs
env:
DOCKER_IMAGE_NAME: "${{ inputs.name }}"
DOCKER_IMAGE: "${{ inputs.registry }}/${{ inputs.registry-org-name }}/${{ inputs.name }}@${{ steps.build-and-push.outputs.digest }}"
run: |
echo "## OUTPUTS" >> $GITHUB_STEP_SUMMARY
echo '**${{ env.DOCKER_IMAGE_NAME }}** image available at:' >> $GITHUB_STEP_SUMMARY
echo '`${{ env.DOCKER_IMAGE }}`' >> $GITHUB_STEP_SUMMARY
echo 'IMAGE=${{ env.DOCKER_IMAGE }}' >> $GITHUB_OUTPUT
# - name: Trigger deploy to stg
# id: deploy-to-ecs
# if: >-
# ${{
# github.ref_name == 'main' &&
# (
# inputs.name == 'backend' ||
# (
# inputs.name == 'frontend' && inputs.deploy-environment == 'stg'
# )
# )
# }}
# env:
# GH_TOKEN: ${{ github.token }}
# run: |
# gh workflow run 'Deploy to ECS' -f "image=${{ steps.docker-build-and-push-outputs.outputs.IMAGE }}" -f "container=${{ inputs.name }}" -f "environment=${{ inputs.deploy-environment }}"