testing go directive change #402
Workflow file for this run
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: ci | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- "develop" | |
- "release/*" | |
pull_request: | |
branches: | |
- "develop" | |
- "release/*" | |
- "feat/*" | |
- "fix/*" | |
- "refactor/*" | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
env: | |
DOCKER_HUB_REPO: portainerci/agent | |
jobs: | |
build_images: | |
strategy: | |
matrix: | |
config: | |
- { platform: linux, arch: amd64, version: "" } | |
- { platform: linux, arch: arm64, version: "" } | |
- { platform: linux, arch: arm, version: "" } | |
- { platform: linux, arch: ppc64le, version: "" } | |
- { platform: windows, arch: amd64, version: 1809 } | |
- { platform: windows, arch: amd64, version: ltsc2022 } | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.draft == false | |
steps: | |
- name: "[preparation] checkout the current branch" | |
uses: actions/[email protected] | |
with: | |
ref: ${{ github.event.inputs.branch }} | |
- name: "[preparation] set up golang" | |
uses: actions/[email protected] | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
go-version-file: go.mod | |
- name: "[preparation] set up qemu" | |
uses: docker/[email protected] | |
- name: "[preparation] set up docker context for buildx" | |
run: docker context create builders | |
- name: "[preparation] set up docker buildx" | |
uses: docker/[email protected] | |
with: | |
endpoint: builders | |
driver-opts: image=moby/buildkit:v0.13.2 | |
- name: "[preparation] docker login" | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: "[preparation] set the container image tag" | |
run: | | |
if [[ "${GITHUB_REF_NAME}" =~ ^release/.*$ ]]; then | |
# use the release branch name as the tag for release branches | |
# for instance, release/2.19 becomes 2.19 | |
CONTAINER_IMAGE_TAG=$(echo $GITHUB_REF_NAME | cut -d "/" -f 2) | |
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then | |
# use pr${{ github.event.number }} as the tag for pull requests | |
# for instance, pr123 | |
CONTAINER_IMAGE_TAG="pr${{ github.event.number }}" | |
else | |
# replace / with - in the branch name | |
# for instance, feature/1.0.0 -> feature-1.0.0 | |
CONTAINER_IMAGE_TAG=$(echo $GITHUB_REF_NAME | sed 's/\//-/g') | |
fi | |
echo "CONTAINER_IMAGE_TAG=${CONTAINER_IMAGE_TAG}-${{ matrix.config.platform }}${{ matrix.config.version }}-${{ matrix.config.arch }}" >> $GITHUB_ENV | |
- name: "[execution] build linux & windows agent binaries" | |
run: | | |
mkdir -p dist/ | |
make all PLATFORM=${{ matrix.config.platform }} ARCH=${{ matrix.config.arch }} | |
env: | |
CONTAINER_IMAGE_TAG: ${{ env.CONTAINER_IMAGE_TAG }} | |
- name: "[execution] build and push docker images" | |
run: | | |
if [ "${{ matrix.config.platform }}" == "windows" ]; then | |
docker buildx build --output=type=registry --platform ${{ matrix.config.platform }}/${{ matrix.config.arch }} --build-arg OSVERSION=${{ matrix.config.version }} -t "${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}" -f build/${{ matrix.config.platform }}/Dockerfile . | |
else | |
docker buildx build --output=type=registry --platform ${{ matrix.config.platform }}/${{ matrix.config.arch }} -t "${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}" -f build/${{ matrix.config.platform }}/Dockerfile . | |
docker buildx build --output=type=registry --platform ${{ matrix.config.platform }}/${{ matrix.config.arch }} -t "${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-alpine" -f build/${{ matrix.config.platform }}/alpine.Dockerfile . | |
fi | |
env: | |
CONTAINER_IMAGE_TAG: ${{ env.CONTAINER_IMAGE_TAG }} | |
build_manifests: | |
runs-on: ubuntu-latest | |
needs: [build_images] | |
if: github.event.pull_request.draft == false | |
steps: | |
- name: "[preparation] docker login" | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: "[preparation] set up docker context for buildx" | |
run: docker version && docker context create builders | |
- name: "[preparation] set up docker buildx" | |
uses: docker/[email protected] | |
with: | |
endpoint: builders | |
- name: "[execution] build and push manifests" | |
run: | | |
if [[ "${GITHUB_REF_NAME}" =~ ^release/.*$ ]]; then | |
# use the release branch name as the tag for release branches | |
# for instance, release/2.19 becomes 2.19 | |
CONTAINER_IMAGE_TAG=$(echo $GITHUB_REF_NAME | cut -d "/" -f 2) | |
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then | |
# use pr${{ github.event.number }} as the tag for pull requests | |
# for instance, pr123 | |
CONTAINER_IMAGE_TAG="pr${{ github.event.number }}" | |
else | |
# replace / with - in the branch name | |
# for instance, feature/1.0.0 -> feature-1.0.0 | |
CONTAINER_IMAGE_TAG=$(echo $GITHUB_REF_NAME | sed 's/\//-/g') | |
fi | |
docker buildx imagetools create -t "${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-linux-amd64" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-linux-arm64" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-linux-arm" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-linux-ppc64le" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-windows1809-amd64" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-windowsltsc2022-amd64" | |
docker buildx imagetools create -t "${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-alpine" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-linux-amd64-alpine" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-linux-arm64-alpine" \ | |
"${DOCKER_HUB_REPO}:${CONTAINER_IMAGE_TAG}-linux-arm-alpine" |