production.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. "on":
  2. push:
  3. tags:
  4. - production
  5. name: Deploy Porter to Production
  6. jobs:
  7. build-go:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Checkout code
  11. uses: actions/checkout@v3
  12. - name: Setup Go Cache
  13. uses: actions/cache@v3
  14. with:
  15. path: |
  16. ~/.cache/go-build
  17. ~/go/pkg/mod
  18. key: porter-go-${{ hashFiles('**/go.sum') }}
  19. restore-keys: porter-go-`
  20. - name: Setup Go
  21. uses: actions/setup-go@v4
  22. with:
  23. go-version-file: go.mod
  24. cache: false
  25. - name: Download Go Modules
  26. run: go mod download
  27. - name: Build Server Binary
  28. run: go build -ldflags="-w -s -X 'main.Version=production'" -o ./bin/app ./cmd/app
  29. - name: Build Migration Binary
  30. run: go build -ldflags '-w -s' -o ./bin/migrate ./cmd/migrate
  31. - name: Store Binaries
  32. uses: actions/upload-artifact@v3
  33. with:
  34. name: go-binaries
  35. path: bin/
  36. build-npm:
  37. runs-on: ubuntu-latest
  38. steps:
  39. - name: Checkout code
  40. uses: actions/checkout@v3
  41. - name: Setup Node
  42. uses: actions/setup-node@v3
  43. with:
  44. node-version: 16
  45. - name: Install NPM Dependencies
  46. run: |
  47. cd dashboard
  48. npm i --legacy-peer-deps
  49. - name: Run NPM Build
  50. run: |
  51. cd dashboard
  52. npm run build
  53. - name: Store NPM Static Files
  54. uses: actions/upload-artifact@v3
  55. with:
  56. name: npm-static-files
  57. path: dashboard/build/
  58. porter-deploy:
  59. runs-on: ubuntu-latest
  60. needs: [build-go, build-npm]
  61. steps:
  62. - name: Checkout code
  63. uses: actions/checkout@v3
  64. - name: Get Go Binaries
  65. uses: actions/download-artifact@v3
  66. with:
  67. name: go-binaries
  68. path: bin/
  69. - name: Get NPM static files
  70. uses: actions/download-artifact@v3
  71. with:
  72. name: npm-static-files
  73. path: build/
  74. - name: Set Github tag
  75. id: vars
  76. run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
  77. - name: Update Porter App
  78. timeout-minutes: 20
  79. uses: porter-dev/porter-update-action@v0.1.0
  80. with:
  81. app: porter-ui
  82. cluster: "9"
  83. host: https://dashboard.internal-tools.getporter.dev
  84. namespace: default
  85. project: "5"
  86. tag: ${{ steps.vars.outputs.sha_short }}
  87. token: ${{ secrets.PORTER_TOKEN_5 }}