|
| 1 | +--- |
| 2 | +name: ci |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "**" |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - "**" |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + name: lint |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - uses: actions/setup-go@v5 |
| 17 | + with: |
| 18 | + go-version-file: "go.mod" |
| 19 | + - name: golangci-lint |
| 20 | + uses: golangci/golangci-lint-action@v8 |
| 21 | + with: |
| 22 | + version: latest |
| 23 | + |
| 24 | + test: |
| 25 | + name: test |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + - uses: actions/setup-go@v5 |
| 30 | + with: |
| 31 | + go-version-file: "go.mod" |
| 32 | + - run: go test -v ./... -covermode=atomic -coverprofile=coverage.out |
| 33 | + |
| 34 | + with: |
| 35 | + files: coverage.out |
| 36 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 37 | + slug: snapp-incubator/nats-helper |
| 38 | + |
| 39 | + build-push: |
| 40 | + name: Build & Push |
| 41 | + runs-on: ubuntu-latest |
| 42 | + needs: |
| 43 | + - lint |
| 44 | + - test |
| 45 | + env: |
| 46 | + REGISTRY: ghcr.io |
| 47 | + USERNAME: ${{ github.repository_owner }} |
| 48 | + REPOSITORY: ${{ github.event.repository.name }} |
| 49 | + steps: |
| 50 | + - name: Checks out our project source code |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Set up QEMU |
| 54 | + uses: docker/setup-qemu-action@v3 |
| 55 | + |
| 56 | + - name: Set up Docker Buildx |
| 57 | + uses: docker/setup-buildx-action@v3 |
| 58 | + |
| 59 | + - uses: docker/login-action@v3 |
| 60 | + with: |
| 61 | + registry: ${{ env.REGISTRY }} |
| 62 | + username: ${{ env.USERNAME }} |
| 63 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + |
| 65 | + - uses: docker/metadata-action@v5 |
| 66 | + id: meta |
| 67 | + with: |
| 68 | + images: ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.REPOSITORY }} |
| 69 | + tags: | |
| 70 | + type=ref,event=branch |
| 71 | + type=ref,event=pr |
| 72 | + type=semver,pattern={{version}} |
| 73 | + type=semver,pattern={{major}}.{{minor}} |
| 74 | +
|
| 75 | + - uses: docker/build-push-action@v6 |
| 76 | + with: |
| 77 | + file: "Dockerfile" |
| 78 | + context: . |
| 79 | + platforms: linux/amd64 |
| 80 | + push: true |
| 81 | + tags: ${{ steps.meta.outputs.tags }} |
| 82 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments