Merge pull request #154 from Staffbase/dependabot/docker/docker-8cd55… #99
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Build & Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| release: | |
| types: [published] | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: Lint | |
| uses: golangci/golangci-lint-action@v8 | |
| with: | |
| version: latest | |
| - name: Test | |
| run: | |
| go test -covermode=atomic -coverpkg=./... -coverprofile=coverage.out | |
| -v ./... | |
| - name: Build | |
| run: go build -o ./yamllint-action . | |
| - name: SonarCloud Scan | |
| uses: SonarSource/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} | |
| push: | |
| name: Push | |
| needs: test | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Docker Metadata | |
| id: metadata | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| staffbase/yamllint-action | |
| tags: | | |
| type=ref,event=branch | |
| type=semver,pattern={{raw}} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Build and Push Docker Image | |
| id: docker_build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: | |
| ${{ github.event_name == 'release' && github.event.action == | |
| 'published' }} | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| tags: ${{ steps.metadata.outputs.tags }} | |
| labels: ${{ steps.metadata.outputs.labels }} |