From a51533f1b88080f4a42850f4e74b8e3908559e7e Mon Sep 17 00:00:00 2001 From: Mike Johanson Date: Fri, 9 Feb 2024 10:35:46 -0700 Subject: [PATCH] ci: add build step in workflow --- .github/workflows/docker-build.yml | 26 +++++++++++--------------- .github/workflows/go.yml | 8 +++++--- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 705fe87a..2e1b8dab 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -3,16 +3,9 @@ name: Docker Image CI on: push: branches: [ main ] + pull_request: + branches: [ main ] workflow_dispatch: - inputs: - docker_registry: - description: 'Registry URL' - required: true - default: 'docker.io/username' - image_name: - description: 'Name you wish to use on the docker image (ex. myapp). This will be tagged with :latest, and the git sha' - required: true - default: 'app' permissions: contents: read @@ -21,21 +14,24 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 with: egress-policy: audit - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.0.0 - name: Build the Docker image - run: docker build . --file Dockerfile --tag ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }}:latest --tag ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }}:${{ github.sha }} + run: docker build --file Dockerfile --tag vprodemo.azurecr.io/console:latest --tag vprodemo.azurecr.io/console:${{ github.sha }} . - name: Docker Login + if: ${{ github.ref == 'refs/heads/main' }} uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 with: registry: ${{ github.event.inputs.docker_registry }} username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} logout: true - - name: Push the Docker image to ${{ github.event.inputs.docker_registry }} - run: docker push ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }} - - name: Push the Docker image to ${{ github.event.inputs.docker_registry }} - run: docker push ${{ github.event.inputs.docker_registry }}/${{ github.event.inputs.image_name }}:${{ github.sha }} + - name: Push the Docker image to the registry + if: ${{ github.ref == 'refs/heads/main' }} + run: docker push vprodemo.azurecr.io/console:latest + - name: Push the Docker image to the registry + if: ${{ github.ref == 'refs/heads/main' }} + run: docker push vprodemo.azurecr.io/console:${{ github.sha }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 99fd7da0..6a4cd666 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 with: egress-policy: audit @@ -53,14 +53,16 @@ jobs: run: go vet ./... if: ${{ matrix.os == 'ubuntu-20.04' }} - name: Run go lint - uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 + uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 if: ${{ matrix.os == 'ubuntu-20.04' }} with: version: latest + - name: build go + run: go build ./cmd/main.go - name: Go Fuzz if: ${{ matrix.os == 'ubuntu-20.04' }} run: go test ./cmd -fuzz=FuzzMe -fuzztime=15s - - uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1 + - uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1 if: ${{ matrix.os == 'ubuntu-20.04' }} name: Upload Coverage Results - name: GitHub Upload Release Artifacts