production.yml 3.0 KB

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