diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 340b1b1..8b01630 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,6 +7,7 @@ on: pull_request: branches: - main + workflow_dispatch: # Allows manual triggering of the workflow jobs: build: @@ -17,9 +18,9 @@ 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: | @@ -27,7 +28,7 @@ jobs: 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" @@ -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 @@ -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: @@ -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: @@ -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) @@ -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 }}