Added support for access token #256
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: Go Build | |
'on': | |
workflow_dispatch: {} | |
push: | |
paths-ignore: | |
- '.github/workflows/*' | |
pull_request: {} | |
jobs: | |
tests: | |
name: Test | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
parallel: [10] | |
index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/checkout@v4 | |
- name: Download JUnit Summary from Previous Workflow | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v4 | |
with: | |
workflow_conclusion: success | |
name: junit-test-summary | |
if_no_artifact_found: warn | |
branch: main | |
- name: Split integration tests | |
id: test_split | |
uses: hashicorp-forge/[email protected] | |
with: | |
index: ${{ matrix.index }} | |
total: ${{ matrix.parallel }} | |
junit-summary: ./junit-test-summary.xml | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_wrapper: false | |
- name: Clone the Terraform provider source | |
run: git clone https://github.com/OctopusDeployLabs/terraform-provider-octopusdeploy.git | |
shell: bash | |
- name: Build the Terraform provider from source | |
run: go build -o terraform-provider-octopusdeploy | |
working-directory: terraform-provider-octopusdeploy | |
- name: Override the location used by Terraform provider | |
run: |- | |
cat <<EOT >> ~/.terraformrc | |
provider_installation { | |
dev_overrides { | |
"octopusdeploylabs/octopusdeploy" = "${{ github.workspace }}/terraform-provider-octopusdeploy" | |
} | |
direct {} | |
} | |
EOT | |
- name: Go test | |
shell: bash | |
env: | |
# Set this to a base64 encoded Octopus license. It is passed to the Octopus docker image, which requires an | |
# encoded license. | |
LICENSE: ${{ secrets.LICENSE }} | |
# Reuse any Terraform plugins between tests | |
TF_PLUGIN_CACHE_DIR: ${{ github.workspace }} | |
OCTOTESTDUMPSTATE: !!str true | |
OCTOTESTDEFAULTSPACEID: Spaces-2 | |
TEST_GIT_REPO: ${{ secrets.TEST_GIT_REPO }} | |
TEST_GIT_PASSWORD: ${{ secrets.GIT_CREDENTIAL }} | |
TEST_GIT_USERNAME: ${{ secrets.TEST_GIT_USERNAME }} | |
GOMAXPROCS: 2 | |
OCTOTESTRETRYCOUNT: 5 | |
TESTCONTAINERS_RYUK_DISABLED: true | |
run: | | |
GOBIN=$PWD/bin go install gotest.tools/gotestsum@latest | |
./bin/gotestsum --junitfile node-summary.xml --format short-verbose -- -run "${{ steps.test_split.outputs.run }}" -timeout 0 ./... | |
- name: Upload test artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: junit-test-summary-${{ matrix.index }} | |
path: node-summary.xml | |
retention-days: 1 | |
tests-combine-summaries: | |
name: Combine Test Reports | |
needs: [ tests ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Install junit-report-merger | |
run: npm install -g junit-report-merger | |
- name: Merge reports | |
run: > | |
jrm ./junit-test-summary.xml | |
"junit-test-summary-0/*.xml" | |
"junit-test-summary-1/*.xml" | |
"junit-test-summary-2/*.xml" | |
"junit-test-summary-3/*.xml" | |
"junit-test-summary-4/*.xml" | |
"junit-test-summary-5/*.xml" | |
"junit-test-summary-6/*.xml" | |
"junit-test-summary-7/*.xml" | |
"junit-test-summary-8/*.xml" | |
"junit-test-summary-9/*.xml" | |
- name: Upload test artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: junit-test-summary | |
path: ./junit-test-summary.xml | |
- name: Report | |
uses: dorny/test-reporter@v1 | |
with: | |
name: Go Tests | |
path: junit-test-summary.xml | |
reporter: java-junit | |
fail-on-error: 'true' | |
build: | |
needs: [ tests-combine-summaries ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v7 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: 5.x | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_wrapper: false | |
- name: Set up Go | |
uses: actions/checkout@v4 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: 5.x | |
- id: determine_version | |
name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
additionalArguments: /overrideconfig mode=Mainline | |
- name: Install Octopus Deploy CLI | |
uses: OctopusDeploy/install-octopus-cli-action@v1 | |
with: | |
version: latest | |
- name: Install Dependencies | |
run: go get ./... | |
shell: bash | |
- name: List Dependencies | |
run: go list -m all > dependencies.txt | |
shell: bash | |
- name: Collect Dependencies | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Dependencies | |
path: dependencies.txt | |
# - name: List Dependency Updates | |
# run: go list -u -m -f "{{if .Update}}{{.}}{{end}}" all > dependencyUpdates.txt | |
# shell: bash | |
# - name: Collect Dependency Updates | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: Dependencies Updates | |
# path: dependencyUpdates.txt | |
- run: go build -ldflags="-X 'entry.Version=${{ steps.determine_version.outputs.semVer }}'" -o octolint_linux_amd64 cmd/cli/octolint.go | |
env: | |
GOOS: linux | |
GOARCH: amd64 | |
CGO_ENABLED: 0 | |
- run: go build -ldflags="-X 'entry.Version=${{ steps.determine_version.outputs.semVer }}'" -o octolint_windows_amd64.exe cmd/cli/octolint.go | |
env: | |
GOOS: windows | |
GOARCH: amd64 | |
CGO_ENABLED: 0 | |
- run: go build -ldflags="-X 'entry.Version=${{ steps.determine_version.outputs.semVer }}'" -o octolint_macos_arm64 cmd/cli/octolint.go | |
env: | |
GOOS: darwin | |
GOARCH: arm64 | |
CGO_ENABLED: 0 | |
- run: go build -ldflags="-X 'main.Version=${{ steps.determine_version.outputs.semVer }}'" -o functions/octolint_linux_amd64_azure cmd/azure/octolint.go | |
env: | |
GOOS: linux | |
GOARCH: amd64 | |
CGO_ENABLED: 0 | |
# Note you must exclude the local.settings.json file from the zip. Otherwise, you get errors like: | |
# Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: custom not found. | |
- run: | | |
zip -r octolint_linux_amd64_azure.zip . -x local.settings.json | |
cp octolint_linux_amd64_azure.zip octolint_azure.${{ steps.determine_version.outputs.semVer }}.zip | |
working-directory: functions | |
- id: create_release | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: ${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }} | |
title: Release ${{ steps.determine_version.outputs.semVer }} Run ${{ github.run_number }} Attempt ${{ github.run_attempt }} | |
draft: ${{ github.ref == 'refs/heads/main' && 'false' || 'true' }} | |
prerelease: ${{ github.ref == 'refs/heads/main' && 'false' || 'true' }} | |
- name: Upload Linux Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: octolint_linux_amd64 | |
asset_name: octolint_linux_amd64 | |
asset_content_type: application/octet-stream | |
- name: Upload Windows Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: octolint_windows_amd64.exe | |
asset_name: octolint_windows_amd64.exe | |
asset_content_type: application/octet-stream | |
- name: Upload macOS Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: octolint_macos_arm64 | |
asset_name: octolint_macos_arm64 | |
asset_content_type: application/octet-stream | |
- name: Upload Azure Functions Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: functions/octolint_linux_amd64_azure.zip | |
asset_name: octolint_linux_amd64_azure.zip | |
asset_content_type: application/octet-stream | |
- name: Push packages to Octopus Deploy | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
uses: OctopusDeploy/push-package-action@v3 | |
env: | |
OCTOPUS_API_KEY: ${{ secrets.COPILOT_OCTOPUS_API }} | |
OCTOPUS_URL: ${{ secrets.COPILOT_OCTOPUS_URL }} | |
OCTOPUS_SPACE: ${{ secrets.COPILOT_OCTOPUS_SPACE }} | |
with: | |
packages: functions/octolint_azure.${{ steps.determine_version.outputs.semVer }}.zip | |
overwrite_mode: OverwriteExisting | |
- name: Create Octopus Release | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
uses: OctopusDeploy/create-release-action@v3 | |
env: | |
OCTOPUS_API_KEY: ${{ secrets.COPILOT_OCTOPUS_API }} | |
OCTOPUS_URL: ${{ secrets.COPILOT_OCTOPUS_URL }} | |
OCTOPUS_SPACE: ${{ secrets.COPILOT_OCTOPUS_SPACE }} | |
with: | |
project: Octopus Octolint Function | |
packages: octolint_azure:${{ steps.determine_version.outputs.semVer }} | |
release_number: ${{ steps.determine_version.outputs.semVer }}+${{ steps.determine_version.outputs.ShortSha }}.${{ github.run_number }}.${{ github.run_attempt }} | |
git_ref: main | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push latest | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: octopussamples/octolint-linux:latest | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push versioned image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: octopussamples/octolint-linux:${{ steps.determine_version.outputs.semVer }} | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push latest arm64 | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
platforms: arm64 | |
tags: octopussamples/octolint-linux-arm64:latest | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push versioned image arm64 | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
platforms: arm64 | |
tags: octopussamples/octolint-linux-arm64:${{ steps.determine_version.outputs.semVer }} | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: https://ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push latest | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ghcr.io/octopussolutionsengineering/octolint-linux:latest | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push versioned image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ghcr.io/octopussolutionsengineering/octolint-linux:${{ steps.determine_version.outputs.semVer }} | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push latest arm64 | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
platforms: arm64 | |
tags: ghcr.io/octopussolutionsengineering/octolint-linux-arm64:latest | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push versioned image arm64 | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
platforms: arm64 | |
tags: ghcr.io/octopussolutionsengineering/octolint-linux-arm64:${{ steps.determine_version.outputs.semVer }} | |
build-args: Version=${{ steps.determine_version.outputs.semVer }} | |
build-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Set up Go | |
uses: actions/checkout@v4 | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v7 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: 5.x | |
- id: determine_version | |
name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
additionalArguments: /overrideconfig mode=Mainline | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- run: go build -ldflags="-X 'entry.Version=${{ steps.determine_version.outputs.semVer }}'" -o octolint_windows_amd64.exe cmd/cli/octolint.go | |
env: | |
GOOS: windows | |
GOARCH: amd64 | |
CGO_ENABLED: 0 | |
- name: Build and push latest | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2019 -t octopussamples/octolint-windows-2019:latest | |
docker push octopussamples/octolint-windows-2019:latest | |
- name: Build and push | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2019 -t octopussamples/octolint-windows-2019:${{ steps.determine_version.outputs.semVer }} | |
docker push octopussamples/octolint-windows-2019:${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push latest 2022 | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2022 -t octopussamples/octolint-windows-2022:latest | |
docker push octopussamples/octolint-windows-2022:latest | |
- name: Build and push | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2022 -t octopussamples/octolint-windows-2022:${{ steps.determine_version.outputs.semVer }} | |
docker push octopussamples/octolint-windows-2022:${{ steps.determine_version.outputs.semVer }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: https://ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push latest | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2019 -t ghcr.io/octopussolutionsengineering/octolint-windows-2019:latest | |
docker push ghcr.io/octopussolutionsengineering/octolint-windows-2019:latest | |
- name: Build and push | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2019 -t ghcr.io/octopussolutionsengineering/octolint-windows-2019:${{ steps.determine_version.outputs.semVer }} | |
docker push ghcr.io/octopussolutionsengineering/octolint-windows-2019:${{ steps.determine_version.outputs.semVer }} | |
- name: Build and push latest 2022 | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2022 -t ghcr.io/octopussolutionsengineering/octolint-windows-2022:latest | |
docker push ghcr.io/octopussolutionsengineering/octolint-windows-2022:latest | |
- name: Build and push | |
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | |
run: | | |
docker build --platform windows/amd64 . -f Dockerfile.windows2022 -t ghcr.io/octopussolutionsengineering/octolint-windows-2022:${{ steps.determine_version.outputs.semVer }} | |
docker push ghcr.io/octopussolutionsengineering/octolint-windows-2022:${{ steps.determine_version.outputs.semVer }} | |
multiarch-image: | |
needs: [ build-windows, build ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create manifest | |
run: > | |
docker run -v $PWD:/build mplatform/manifest-tool | |
--username=${{ secrets.DOCKERHUB_USERNAME }} | |
--password=${{ secrets.DOCKERHUB_TOKEN }} | |
push from-spec /build/manifest-octolint.yaml | |
- name: Create manifest GHCR | |
run: > | |
docker run -v $PWD:/build mplatform/manifest-tool | |
--username=${{ github.actor }} | |
--password=${{ secrets.GITHUB_TOKEN }} | |
push from-spec /build/manifest-octolint-ghcr.yaml | |
permissions: | |
id-token: write | |
checks: write | |
contents: write | |
packages: write |