build.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. name: build and push
  2. on:
  3. push:
  4. branches: [ master ]
  5. pull_request:
  6. branches: [ master ]
  7. jobs:
  8. build:
  9. name: Build and push
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Set up Go 1.18
  13. uses: actions/setup-go@v3
  14. with:
  15. go-version: 1.18
  16. id: go
  17. - name: Check out code into the Go module directory
  18. uses: actions/checkout@v3
  19. - uses: actions/setup-node@v3
  20. with:
  21. node-version: lts/*
  22. - name: Setup yarn
  23. run: npm install -g yarn
  24. - name: Install dependencies
  25. run: yarn install
  26. working-directory: ./web
  27. - name: Compile JS and CSS
  28. run: yarn compile
  29. working-directory: ./web
  30. - name: Get dependencies
  31. run: go get -v -t -d ./...
  32. - name: Build
  33. run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v .
  34. - name: Login to Docker Hub
  35. if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
  36. uses: docker/login-action@v1
  37. with:
  38. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  39. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  40. - name: Set up Docker Buildx
  41. if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
  42. uses: docker/setup-buildx-action@v1
  43. - name: Build and push
  44. if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
  45. uses: docker/build-push-action@v2
  46. with:
  47. context: .
  48. file: ./Dockerfile
  49. push: true
  50. tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sakuin:latest