dev_cli.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. on:
  2. workflow_run:
  3. workflows: ["Deploy Porter to Internal Tooling"]
  4. branches: [master]
  5. types:
  6. - completed
  7. name: Release dev cli and run integration tests
  8. jobs:
  9. build-linux:
  10. name: Build Linux binaries
  11. runs-on: ubuntu-latest
  12. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  13. steps:
  14. - name: Checkout code
  15. uses: actions/checkout@v3
  16. - name: Set up Go
  17. uses: actions/setup-go@v4
  18. with:
  19. cache: false
  20. go-version: '1.20.5'
  21. go-version-file: go.mod
  22. - name: Build Linux binaries
  23. run: |
  24. go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd/config.Version=dev_${{ github.sha }}' -X 'github.com/porter-dev/porter/cli/cmd/errors.SentryDSN=${{secrets.SENTRY_DSN}}'" -a -tags cli -o ./porter ./cli &
  25. wait
  26. env:
  27. GOOS: linux
  28. GOARCH: amd64
  29. CGO_ENABLED: 0
  30. - name: Zip Linux binaries
  31. run: |
  32. mkdir -p ./release/linux
  33. zip --junk-paths ./release/linux/porter_dev_${{ github.sha }}_Linux_x86_64.zip ./porter
  34. - name: Upload binaries
  35. uses: actions/upload-artifact@v3
  36. with:
  37. path: ./release/linux
  38. name: linux-binaries
  39. retention-days: 1
  40. release:
  41. name: Zip binaries, create release and upload assets
  42. runs-on: ubuntu-latest
  43. needs:
  44. - build-linux
  45. steps:
  46. - name: Download binaries
  47. uses: actions/download-artifact@v3
  48. with:
  49. name: linux-binaries
  50. path: release/linux
  51. - name: Create Release
  52. id: create_release
  53. uses: softprops/action-gh-release@v1
  54. with:
  55. tag_name: dev_${{ github.sha }}
  56. name: Release dev cli for ${{ github.sha }}
  57. token: ${{ secrets.GITHUB_TOKEN }}
  58. draft: false
  59. prerelease: true
  60. - name: Upload Linux CLI Release Asset
  61. id: upload-linux-cli-release-asset
  62. uses: actions/upload-release-asset@v1
  63. env:
  64. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  65. GITHUB_TAG: dev_${{ github.sha }}
  66. with:
  67. upload_url: ${{ steps.create_release.outputs.upload_url }}
  68. asset_path: ./release/linux/porter_dev_${{ github.sha }}_Linux_x86_64.zip
  69. asset_name: porter_dev_${{ github.sha }}_Linux_x86_64.zip
  70. asset_content_type: application/zip
  71. build-push-docker-cli:
  72. name: Build a new porter-cli docker image and push to dev tag
  73. runs-on: ubuntu-latest
  74. needs: release
  75. steps:
  76. - name: Checkout
  77. uses: actions/checkout@v3
  78. - name: Login to GHCR
  79. id: login-ghcr
  80. run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
  81. - name: Build
  82. run: |
  83. docker build ./services/porter_cli_container \
  84. -t ghcr.io/porter-dev/porter/porter-cli:dev \
  85. -f ./services/porter_cli_container/Dockerfile \
  86. --build-arg VERSION=dev \
  87. --build-arg SENTRY_DSN=${{secrets.SENTRY_DSN}}
  88. - name: Push to GHCR
  89. run: |
  90. docker tag ghcr.io/porter-dev/porter/porter-cli:dev ghcr.io/porter-dev/porter/porter-cli:dev
  91. docker push ghcr.io/porter-dev/porter/porter-cli:dev
  92. run-integration-tests:
  93. name: run integration tests to test new build
  94. runs-on: ubuntu-latest
  95. needs: build-push-docker-cli
  96. steps:
  97. - name: Porter app run
  98. uses: porter-dev/porter-cli-action@v0.1.0
  99. with:
  100. command: app run app-integration-tests -- /app/trigger
  101. env:
  102. PORTER_CLUSTER: "142"
  103. PORTER_HOST: https://dashboard.internal-tools.porter.run
  104. PORTER_PROJECT: "301"
  105. PORTER_TOKEN: ${{ secrets.APP_INTEGRATION_PROJECT_TOKEN }}
  106. PORTER_SERVICE: porter
  107. PORTER_COMMIT: ${{ github.sha }}