SMRE-439 #501
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: example | |
on: [pull_request] | |
env: | |
product_name: actions-docker-build | |
product_version: 1.0.0 | |
defaults: | |
run: | |
shell: bash | |
# Usually we would be in root, but this is just an example. | |
working-directory: example/ | |
jobs: | |
build-product-binary: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- { go: "1.16", goos: "linux", goarch: "386" } | |
- { go: "1.16", goos: "linux", goarch: "amd64" } | |
- { go: "1.16", goos: "linux", goarch: "arm" } | |
- { go: "1.16", goos: "linux", goarch: "arm64" } | |
- { go: "1.16", goos: "freebsd", goarch: "386" } | |
- { go: "1.16", goos: "freebsd", goarch: "amd64" } | |
- { go: "1.16", goos: "windows", goarch: "386" } | |
- { go: "1.16", goos: "windows", goarch: "amd64" } | |
- { go: "1.16", goos: "solaris", goarch: "amd64" } | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
with: | |
go-version: ${{ matrix.go }} | |
- name: Compile Binary | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
run: | | |
go build -o "$product_name" . | |
zip "${{ env.product_name }}_${{ env.product_version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip" "$product_name" | |
- name: Upload product artifact. | |
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 | |
with: | |
path: example/${{ env.product_name }}_${{ env.product_version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
name: ${{ env.product_name }}_${{ env.product_version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
if-no-files-found: error | |
build-linux-image: | |
needs: | |
- build-product-binary | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
# We only support building images for linux platforms, | |
# so we only specify arch here. | |
- { arch: "386" } | |
- { arch: "amd64" } | |
- { arch: "arm" } | |
- { arch: "arm64" } | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Build | |
# To run the example with the current commit use 'uses: ./' | |
uses: ./ | |
# For real usages, you will reference the action like this: | |
# 'uses: hashicorp/actions-docker-build@v1' | |
with: | |
version: ${{env.product_version}} | |
target: default | |
arch: ${{ matrix.arch }} | |
# Production tags. (These are the tags used for the multi-arch images | |
# we eventually push, they must never be architecture/platform-specific.) | |
tags: | | |
docker.io/hashicorp/${{env.product_name}}:${{env.product_version}} | |
public.ecr.aws/hashicorp/${{env.product_name}}:${{env.product_version}} | |
# Dev tags are pushed more frequently by downstream processes. They also | |
# must not reference the architecture. | |
dev_tags: | | |
docker.io/hashicorppreview/${{env.product_name}}:${{env.product_version}}-dev | |
# Usually you wouldn't need to set workdir, but this is just an example. | |
workdir: example/ | |
build-windows-image: | |
needs: | |
- build-product-binary | |
strategy: | |
matrix: | |
include: | |
- { runner: "windows-2022", arch: "amd64", Dockerfile: "Dockerfile.windows-2022" } | |
- { runner: "windows-2019", arch: "amd64", Dockerfile: "Dockerfile.windows-2019" } | |
runs-on: ${{matrix.runner}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Build | |
# To run the example with the current commit use 'uses: ./' | |
uses: ./ | |
# For real usages, you will reference the action like this: | |
# 'uses: hashicorp/actions-docker-build@v1' | |
with: | |
version: ${{env.product_version}} | |
target: default | |
arch: ${{ matrix.arch }} | |
# Go's -output flag during build doesn't auto-add .exe for windows, so we'll just ignore it here. | |
bin_name: actions-docker-build | |
# Production tags. (These are the tags used for the multi-arch images | |
# we eventually push, they need not be architecture/platform-specific.) | |
tags: | | |
docker.io/hashicorp/${{env.product_name}}:${{env.product_version}} | |
public.ecr.aws/hashicorp/${{env.product_name}}:${{env.product_version}} | |
# Dev tags are pushed more frequently by downstream processes. They also | |
# need not reference the architecture. | |
dev_tags: | | |
docker.io/hashicorppreview/${{env.product_name}}:${{env.product_version}}-dev | |
# Usually you wouldn't need to set workdir, but this is just an example. | |
workdir: example/ | |
Dockerfile: ${{matrix.Dockerfile}} |