production.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. cache: false
  24. go-version-file: go.mod
  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 API
  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 }}
  93. - name: Update Porter Auth
  94. timeout-minutes: 20
  95. uses: porter-dev/porter-update-config-action@v0.1.0
  96. with:
  97. app: porter-auth
  98. cluster: "9"
  99. host: https://dashboard.internal-tools.porter.run
  100. namespace: default
  101. project: "5"
  102. tag: ${{ steps.vars.outputs.sha_short }}
  103. token: ${{ secrets.PORTER_TOKEN_5 }}
  104. deploy-worker-pool:
  105. runs-on: ubuntu-latest
  106. needs: [build-go, build-npm] # don't run this step unless these finish successfully
  107. steps:
  108. - name: Checkout code
  109. uses: actions/checkout@v3
  110. - name: Set Github tag
  111. id: vars
  112. run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
  113. - name: Update Worker Pool (revision cull job)
  114. timeout-minutes: 20
  115. uses: porter-dev/porter-update-action@v0.1.0
  116. with:
  117. app: cull-helm-revisions
  118. cluster: "9"
  119. host: https://dashboard.internal-tools.porter.run
  120. namespace: default
  121. project: "5"
  122. tag: ${{ steps.vars.outputs.sha_short }}
  123. token: ${{ secrets.PORTER_TOKEN_5 }}