Debugging #114
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: Build | |
on: | |
push: | |
branches: [ main, argocd-integration, build_improvments, debugging ] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Go | |
uses: actions/setup-go@v1 | |
with: | |
go-version: '1.16' | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Build the go application | |
run: | | |
go build -o bin/gitops \ | |
-ldflags "-X github.com/entigolabs/entigo-k8s-gitops/internal/app/gitops/common.version=${{ github.run_number }} \ | |
-X github.com/entigolabs/entigo-k8s-gitops/internal/app/gitops/common.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | |
-X github.com/entigolabs/entigo-k8s-gitops/internal/app/gitops/common.gitCommit=${GITHUB_SHA} \ | |
-X github.com/entigolabs/entigo-k8s-gitops/internal/app/gitops/common.gitTreeState=clean \ | |
-linkmode external -extldflags -static" \ | |
cmd/gitops/main.go | |
- name: Analyze with SonarCloud | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: gitops-${{ github.run_number }} | |
path: bin/gitops | |
- name: Log in to Docker Hub | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: entigolabs/entigo-k8s-gitops | |
tags: | | |
type=raw,value={{branch}}-${{ github.run_number }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
file: Dockerfile.github | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Create Release | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/debugging' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: v${{ github.run_number }} | |
release_name: Release ${{ github.run_number }} | |
body: | | |
${{ github.event.head_commit.message}} | |
draft: true | |
prerelease: false | |
- name: Upload Release Artifact | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/debugging' | |
id: upload_release_asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: bin/gitops | |
asset_name: entigo-k8s-gitops-${{ github.run_number }} | |
asset_content_type: application/octet-stream |