forked from sqlfluff/sqlfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish-sqlfluff-docker-image-to-dockerhub.yaml
More file actions
70 lines (63 loc) · 2.35 KB
/
Copy pathpublish-sqlfluff-docker-image-to-dockerhub.yaml
File metadata and controls
70 lines (63 loc) · 2.35 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
# Create and push Docker image of latest release to DockerHub.
name: Publish SQLFluff DockerHub Version
on:
release:
types:
- published
workflow_dispatch:
# Create tag for integration test.
env:
TEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/sqlfluff:test
jobs:
docker:
runs-on: ubuntu-latest
steps:
# Get the version of latest release in
# order to tag published Docker image.
- name: Get latest release name
id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
# Setup QEMU and Buildx to allow for multi-platform builds.
- name: Set up QEMU
id: docker_qemu
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: docker_buildx
uses: docker/setup-buildx-action@v3
# Authenticate with DockerHub.
- name: Login to DockerHub
id: docker_login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build amd64 image to use in the integration test.
- name: Build and export to Docker
id: docker_build
uses: docker/build-push-action@v5
with:
load: true
tags: ${{ env.TEST_TAG }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/sqlfluff:latest
cache-to: type=inline
# Integration test to validate newly created image is working.
- name: Test Docker image
id: docker_test
run: |
echo "SELECT 1" > test.sql
docker run --rm -i -v $PWD:/sql ${{ env.TEST_TAG }} lint --dialect ansi /sql/test.sql
# Build arm64 image (amd64 is cached from docker_build step) and export to DockerHub.
# N.B. We tag this image as both latest and with its version number.
- name: Build and push
id: docker_build_push
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/sqlfluff:latest
${{ secrets.DOCKERHUB_USERNAME }}/sqlfluff:${{ steps.latest_release.outputs.release }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/sqlfluff:latest
cache-to: type=inline