From ddf1b161aac8558807efb1149d1d6f7ddf23cb9b Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 25 Oct 2023 10:52:46 +0800 Subject: [PATCH] chore: refactor GitHub Actions workflows - Fix a typo in the cron expression for the codeql.yml workflow - Change the language specification from ['go'] to ['go'] in the codeql.yml workflow - Change the version specification from 'v*' to 'v*' in the docker.yml workflow - Change the branch specification from 'master' to 'master' in the docker.yml workflow - Change the go-version specification from '^1' to '^1.21' in the docker.yml workflow - Remove the name "Set up QEMU" in the docker.yml workflow - Remove the name "Set up Docker Buildx" in the docker.yml workflow - Remove the name "Login to Docker Hub" in the docker.yml workflow - Remove the name "Login to GitHub Container Registry" in the docker.yml workflow - Remove the name "Docker meta" in the docker.yml workflow - Remove the name "Build and push" in the docker.yml workflow - Change the version specification from '*' to '*' in the goreleaser.yml workflow - Remove the name "Checkout" in the goreleaser.yml workflow - Remove the name "Setup go" in the goreleaser.yml workflow - Change the go-version specification from '^1' to '^1' in the goreleaser.yml workflow - Remove the name "Run GoReleaser" in the goreleaser.yml workflow - Change the go-version specification from '^1' to '^1' in the lint.yml workflow Signed-off-by: Bo-Yi Wu --- .github/workflows/codeql.yml | 34 ++++++++++++++++---------------- .github/workflows/docker.yml | 27 +++++++++++-------------- .github/workflows/goreleaser.yml | 13 +++++------- .github/workflows/lint.yml | 2 +- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2d9bcdd..1f1b0d7 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,12 +13,12 @@ name: "CodeQL" on: push: - branches: [ master ] + branches: [master] pull_request: # The branches below must be a subset of the branches above - branches: [ master ] + branches: [master] schedule: - - cron: '41 23 * * 6' + - cron: "41 23 * * 6" jobs: analyze: @@ -32,23 +32,23 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'go' ] + language: ["go"] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index aef1471..872469f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,10 +5,10 @@ on: branches: - master tags: - - 'v*' + - "v*" pull_request: branches: - - 'master' + - "master" jobs: build-docker: @@ -17,42 +17,38 @@ jobs: - name: Setup go uses: actions/setup-go@v4 with: - go-version: '^1' + go-version: "^1.21" - name: Checkout repository uses: actions/checkout@v3 with: fetch-depth: 0 - name: Build binary - run : | + run: | make build_linux_amd64 make build_linux_arm make build_linux_arm64 - - - name: Set up QEMU + + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub + - name: Login to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GitHub Container Registry + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker meta + - name: Docker meta id: docker-meta uses: docker/metadata-action@v4 with: @@ -65,8 +61,7 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - - - name: Build and push + - name: Build and push uses: docker/build-push-action@v4 with: context: . diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 565c382..c843afa 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -3,7 +3,7 @@ name: Goreleaser on: push: tags: - - '*' + - "*" permissions: contents: write @@ -12,19 +12,16 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - - - name: Setup go + - name: Setup go uses: actions/setup-go@v4 with: - go-version: '^1' + go-version: "^1" - - - name: Run GoReleaser + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: # either 'goreleaser' (default) or 'goreleaser-pro' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 094abf6..73a17ac 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: - name: Setup go uses: actions/setup-go@v4 with: - go-version: '^1' + go-version: "^1" - name: Checkout repository uses: actions/checkout@v3 - name: Setup golangci-lint