-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (69 loc) · 2.79 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Docker
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
setup:
name: setup
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.sha.outputs.sha_short }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: generate short commit hash
id: sha
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
build:
env:
ORG: "parsertongue"
IMAGE_NAME: "swagger-codegen-cli"
TAG: "latest"
DOCKERFILE: "Dockerfile"
JAR_VERSION: "3.0.32"
name: Publish images
runs-on: "ubuntu-latest"
needs: setup
steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@v2
# Setup docker
- name: Set up QEMU
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
continue-on-error: false
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Build AMD64 image"
run: |
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${JAR_VERSION}/swagger-codegen-cli-${JAR_VERSION}.jar -O swagger-codegen-cli.jar
docker buildx build --load --platform=linux/amd64 -f ${DOCKERFILE} -t "${ORG}/${IMAGE_NAME}:amd64" .
- name: "Test AMD64 image"
run: |
docker run "${ORG}/${IMAGE_NAME}:amd64" generate --help
# - name: "Build ARM64 image"
# run: |
# wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${JAR_VERSION}/swagger-codegen-cli-${JAR_VERSION}.jar -O swagger-codegen-cli.jar
# docker buildx build --load --platform=linux/arm64 -f ${DOCKERFILE} -t "${ORG}/${IMAGE_NAME}:arm64" .
# - name: "Test ARM64 image"
# run: |
# docker run "${ORG}/${IMAGE_NAME}:arm64" generate --help
- name: "Publish multi-platform docker image"
if: github.ref == 'refs/heads/main'
run: |
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${JAR_VERSION}/swagger-codegen-cli-${JAR_VERSION}.jar -O swagger-codegen-cli.jar
docker buildx build --platform=linux/amd64,linux/arm64 -f ${DOCKERFILE} --push -t "${ORG}/${IMAGE_NAME}:${TAG}" -t "${ORG}/${IMAGE_NAME}:${JAR_VERSION}" -t "${ORG}/${IMAGE_NAME}:${{ needs.setup.outputs.sha_short }}" .
# # see https://github.com/marketplace/actions/docker-hub-description#action-inputs
# - name: Update DockerHub Description
# uses: peter-evans/dockerhub-description@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# # NOTE: only a Docker password works for this as of now :(
# password: ${{ secrets.DOCKERHUB_PASSWORD }}
# repository: ${ORG}/${IMAGE_NAME}
# # readme-filepath: ./path/to/README.md