go.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. name: build
  2. on:
  3. push:
  4. branches: [ master, dev ]
  5. pull_request:
  6. branches: [ master ]
  7. env:
  8. REGISTRY: ghcr.io
  9. IMAGE_NAME: ${{ github.repository }}
  10. jobs:
  11. build:
  12. name: Build
  13. runs-on: ubuntu-latest
  14. steps:
  15. - name: Set up Go 1.18
  16. uses: actions/setup-go@v3
  17. with:
  18. go-version: 1.18
  19. id: go
  20. - name: Check out code into the Go module directory
  21. uses: actions/checkout@v3
  22. - name: Get dependencies
  23. run: go mod tidy
  24. - name: Build
  25. run: make build
  26. - name: Log in to the Container registry
  27. uses: docker/login-action@v2
  28. if: startsWith(${{github.ref}}, 'refs/tags/')
  29. with:
  30. registry: ${{ env.REGISTRY }}
  31. username: ${{ github.actor }}
  32. password: ${{ secrets.GITHUB_TOKEN }}
  33. - name: Extract metadata (tags, labels) for Docker
  34. id: meta
  35. if: startsWith(${{github.ref}}, 'refs/tags/')
  36. uses: docker/metadata-action@v4
  37. with:
  38. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  39. flavor: |
  40. latest=auto
  41. tags: |
  42. type=schedule
  43. type=ref,event=tag
  44. type=sha,prefix=,format=long,enable=true,priority=100
  45. - name: Build and push Docker image
  46. uses: docker/build-push-action@v3
  47. if: startsWith(${{github.ref}}, 'refs/tags/')
  48. with:
  49. context: .
  50. file: scripts/Dockerfile
  51. push: true
  52. tags: ${{ steps.meta.outputs.tags }}
  53. labels: ${{ steps.meta.outputs.labels }}