forked from AndreZiviani/ec2-price-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (65 loc) · 2.12 KB
/
build-image.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
name: docker build ec2-price-exporter
env:
registry: ghcr.io
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
custom_tag:
description: 'Tag to build'
required: true
type: string
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Get image tags
id: tag
run: |
if [[ ${GITHUB_REF_TYPE} == tag ]]; then
tag=${GITHUB_REF##*/}
else
tag=${{ github.event.inputs.custom_tag }}
fi
echo "Tag: ${tag}"
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Check out the repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ steps.tag.outputs.tag }}
- name: Create docker context
run: |
docker context create ctx
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
endpoint: ctx
driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760,env.BUILDKIT_STEP_LOG_MAX_SPEED=10485760
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
echo "Build tag ${{ steps.tag.outputs.tag }}"
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.registry }}/${{ github.repository }}:${{ steps.tag.outputs.tag }}, ${{ env.registry }}/${{ github.repository }}:latest
builder: ${{ steps.buildx.outputs.name }}