ci.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. name: 'CI'
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'wiki/**'
  6. - 'wiki_static/**'
  7. jobs:
  8. build:
  9. runs-on: [self-hosted]
  10. steps:
  11. - name: Checkout code
  12. uses: actions/checkout@v2
  13. with:
  14. fetch-depth: 0
  15. submodules: true
  16. - uses: satackey/action-docker-layer-caching@v0.0.8
  17. continue-on-error: true
  18. with:
  19. key: docker-cache-${{ hashFiles('docker/**') }}-{hash}
  20. restore-keys: docker-cache-${{ hashFiles('docker/**') }}-
  21. - name: Build docker image
  22. uses: ./.github/actions/docker
  23. - name: Check syntax
  24. uses: ./.github/actions/docker
  25. continue-on-error: false
  26. with:
  27. run: /syntax_check.sh
  28. - name: Build local testing firmware in docker
  29. uses: ./.github/actions/docker
  30. with:
  31. run: make -C firmware TARGET=local
  32. - name: Run local tests
  33. uses: ./.github/actions/docker
  34. with:
  35. run: make -C firmware TARGET=local APP_TEST=1 run
  36. - name: Build F4 bootloader in docker
  37. uses: ./.github/actions/docker
  38. with:
  39. run: make -C bootloader TARGET=f4
  40. - name: Publish F4 bootloader artifacts
  41. uses: actions/upload-artifact@v2
  42. with:
  43. name: bootloader_f4
  44. path: |
  45. bootloader/.obj/f4/bootloader.elf
  46. bootloader/.obj/f4/bootloader.bin
  47. bootloader/.obj/f4/bootloader.hex
  48. if-no-files-found: error
  49. retention-days: 7
  50. - name: Build F4 firmware in docker
  51. uses: ./.github/actions/docker
  52. with:
  53. run: make -C firmware TARGET=f4 APP_RELEASE=1
  54. - name: Publish F4 firmware artifacts
  55. uses: actions/upload-artifact@v2
  56. with:
  57. name: firmware_f4
  58. path: |
  59. firmware/.obj/f4/firmware.elf
  60. firmware/.obj/f4/firmware.bin
  61. firmware/.obj/f4/firmware.hex
  62. if-no-files-found: error
  63. retention-days: 7
  64. upload:
  65. name: Upload artifacts to external storage
  66. needs: build
  67. runs-on: [self-hosted]
  68. steps:
  69. - name: Create directory for artifacts
  70. run: mkdir artifacts
  71. - name: Get bootloader
  72. uses: actions/download-artifact@v2
  73. with:
  74. name: bootloader_f4
  75. path: artifacts/bootloader
  76. - name: Get firmware
  77. uses: actions/download-artifact@v2
  78. with:
  79. name: firmware_f4
  80. path: artifacts/firmware
  81. - name: Upload bootloader
  82. uses: burnett01/rsync-deployments@4.1
  83. with:
  84. switches: -avzp --delete
  85. path: artifacts/bootloader
  86. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  87. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  88. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  89. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  90. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  91. - name: Upload firmware
  92. uses: burnett01/rsync-deployments@4.1
  93. with:
  94. switches: -avzp --delete
  95. path: artifacts/firmware
  96. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  97. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  98. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  99. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  100. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  101. fullfirmware:
  102. name: Create latest full firmware
  103. needs: upload
  104. if: github.ref == 'refs/heads/master'
  105. runs-on: [self-hosted]
  106. steps:
  107. - name: Get bootloader
  108. uses: actions/download-artifact@v2
  109. with:
  110. name: bootloader_f4
  111. path: bootloader
  112. - name: Get firmware
  113. uses: actions/download-artifact@v2
  114. with:
  115. name: firmware_f4
  116. path: firmware
  117. - name: cp
  118. run: cp ./bootloader/bootloader.bin full_firmware_latest.bin
  119. - name: truncate
  120. run: truncate -s 32768 full_firmware_latest.bin
  121. - name: cat
  122. run: cat ./firmware/firmware.bin >> full_firmware_latest.bin
  123. - name: ls
  124. run: ls -R
  125. - name: Upload fullfirmware
  126. uses: burnett01/rsync-deployments@4.1
  127. with:
  128. switches: -avzp --delete
  129. path: full_firmware_latest.bin
  130. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  131. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  132. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  133. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  134. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  135. genpic:
  136. name: Generate pic
  137. needs: fullfirmware
  138. if: github.ref == 'refs/heads/master'
  139. runs-on: [self-hosted]
  140. steps:
  141. - name: Checkout code
  142. uses: actions/checkout@v2
  143. with:
  144. fetch-depth: 0
  145. ref: master
  146. submodules: true
  147. - name: Set test env
  148. run: echo "NUMBER_OF_COMMITS=$(git rev-list --count HEAD)" >> $GITHUB_ENV
  149. - name: Test output NUMBER_OF_COMMITS
  150. run: echo $NUMBER_OF_COMMITS
  151. - name: Test output date
  152. run: |
  153. GET_DATE=$(date +"%b %d")
  154. PREP_DATE=$(echo "${GET_DATE^^}")
  155. echo "PREP_DATE=$PREP_DATE" >> $GITHUB_ENV
  156. - name: Test output PREP_DATE
  157. run: echo $PREP_DATE
  158. - name: Gen pic
  159. run: convert ./.github/assets/latest-firmware-template.png -font ./.github/assets/Born2bSportyV2.ttf -weight 700 -pointsize 140 -annotate +900+330 "$NUMBER_OF_COMMITS $PREP_DATE" latest-firmware-banner.png
  160. - name: Upload pic
  161. uses: burnett01/rsync-deployments@4.1
  162. with:
  163. switches: -avzp --delete
  164. path: latest-firmware-banner.png
  165. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  166. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  167. remote_port: ${{ secrets.RSYNC_DEPLOY_PORT }}
  168. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  169. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}