ci.yml 5.7 KB

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