Skip to content

Commit

Permalink
Update build.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
hany-mhajna-payu-gpo authored Nov 28, 2024
1 parent 2b11ee9 commit 2ecd857
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
workflow_dispatch: # Allows manual triggering of the workflow

jobs:
build:
Expand All @@ -17,17 +18,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Get merge request latest commit
- name: Get commit message
id: parse-commit
if: ${{ github.event_name == 'pull_request' }}
run: |
msg=$(git show -s --format=%s)
echo "head_commit_message=${msg}" >> $GITHUB_ENV
- name: Setup Go 1.21
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: "1.21"

Expand Down Expand Up @@ -67,10 +68,8 @@ jobs:
CGO_ENABLED: 0

- name: Run golangci-lint
# You may pin to the exact commit or the version.
# uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc
if: ${{ github.event_name == 'pull_request' && !contains(env.head_commit_message, '#skip-lint') }}
uses: golangci/golangci-lint-action@v3.2.0
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m
skip-pkg-cache: true
Expand All @@ -88,13 +87,13 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push pr (egressd collector)
- name: Build and push PR (egressd collector)
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v3
with:
Expand All @@ -104,7 +103,7 @@ jobs:
push: ${{ github.event_name == 'pull_request' }}
tags: ghcr.io/castai/egressd/egressd:${{ github.sha }}

- name: Build and push pr (egressd exporter)
- name: Build and push PR (egressd exporter)
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v3
with:
Expand All @@ -121,7 +120,7 @@ jobs:
context: .
platforms: linux/arm64,linux/amd64
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ghcr.io/castai/egressd/egressd:${{ github.sha }}

- name: Build and push main (egressd exporter)
Expand All @@ -131,25 +130,25 @@ jobs:
context: .
platforms: linux/arm64,linux/amd64
file: ./Dockerfile.exporter
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: ghcr.io/castai/egressd/egressd-exporter:${{ github.sha }}

e2e:
name: E2E
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Go 1.21
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: "1.21"

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down

0 comments on commit 2ecd857

Please sign in to comment.