2
0

production.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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'" -tags ee -o ./bin/app ./cmd/app
  29. - name: Build Migration Binary
  30. run: go build -ldflags '-w -s' -tags ee -o ./bin/migrate ./cmd/migrate
  31. - name: Compress binaries
  32. run: |
  33. upx bin/* --best --lzma
  34. - name: Store Binaries
  35. uses: actions/upload-artifact@v3
  36. with:
  37. name: go-binaries
  38. path: bin/
  39. retention-days: 1
  40. build-npm:
  41. runs-on: ubuntu-latest
  42. steps:
  43. - name: Checkout code
  44. uses: actions/checkout@v3
  45. - name: Setup Node
  46. uses: actions/setup-node@v3
  47. with:
  48. node-version: 16
  49. - name: Install NPM Dependencies
  50. run: |
  51. cd dashboard
  52. npm i --legacy-peer-deps
  53. - name: Run NPM Build
  54. run: |
  55. cd dashboard
  56. npm run build
  57. - name: Store NPM Static Files
  58. uses: actions/upload-artifact@v3
  59. with:
  60. name: npm-static-files
  61. path: dashboard/build/
  62. retention-days: 1
  63. porter-deploy:
  64. runs-on: ubuntu-latest
  65. needs: [build-go, build-npm]
  66. steps:
  67. - name: Checkout code
  68. uses: actions/checkout@v3
  69. - name: Get Go Binaries
  70. uses: actions/download-artifact@v3
  71. with:
  72. name: go-binaries
  73. path: bin/
  74. - name: Get NPM static files
  75. uses: actions/download-artifact@v3
  76. with:
  77. name: npm-static-files
  78. path: build/
  79. - name: Set Github tag
  80. id: vars
  81. run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
  82. - name: Update Porter App
  83. timeout-minutes: 20
  84. uses: porter-dev/porter-update-action@v0.1.0
  85. with:
  86. app: porter-ui
  87. cluster: "9"
  88. host: https://dashboard.internal-tools.porter.run
  89. namespace: default
  90. project: "5"
  91. tag: ${{ steps.vars.outputs.sha_short }}
  92. token: ${{ secrets.PORTER_TOKEN_5 }}