From 0025b0592261b61029f1815d3386ac546703ac11 Mon Sep 17 00:00:00 2001 From: Mahdi Shojaee Date: Sun, 27 Oct 2024 21:45:54 +0330 Subject: [PATCH] Update github workflow --- .github/workflows/build-and-test.yml | 33 ---------- .github/workflows/build-test-and-deploy.yml | 73 +++++++++++++++++++++ 2 files changed, 73 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/build-test-and-deploy.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml deleted file mode 100644 index ca2643e..0000000 --- a/.github/workflows/build-and-test.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - -name: Build and Test - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -permissions: - contents: write - pages: write - id-token: write - -jobs: - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.18' - - - name: Build - run: go build -v ./... - - - name: Test - run: go test -v ./... diff --git a/.github/workflows/build-test-and-deploy.yml b/.github/workflows/build-test-and-deploy.yml new file mode 100644 index 0000000..4cae0eb --- /dev/null +++ b/.github/workflows/build-test-and-deploy.yml @@ -0,0 +1,73 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Build, Test, and Deploy + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + # Add manual trigger + workflow_dispatch: + +permissions: + contents: write + pages: write + id-token: write + +# Add concurrency group for pages deployment +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.18' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... + + deploy-benchmark: + needs: build # This ensures deploy runs after successful build + # Only run deployment on master branch pushes or manual triggers + if: github.ref == 'refs/heads/master' + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.18' + + - name: Build benchmark results viewer + working-directory: ./charts + run: go run main.go -build + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: './charts/benchmark-results-viewer' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4