joystream-node-docker.yml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: joystream-node-docker
  2. on: push
  3. jobs:
  4. build:
  5. name: Build joystream/node Docker image
  6. if: github.repository == 'Joystream/joystream'
  7. runs-on: ubuntu-latest
  8. steps:
  9. - uses: actions/checkout@v1
  10. - uses: actions/setup-node@v1
  11. with:
  12. node-version: '14.x'
  13. - id: compute_shasum
  14. name: Compute runtime code shasum
  15. run: |
  16. export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
  17. echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
  18. - name: Setup cache directory
  19. run: mkdir ~/docker-images
  20. - name: Cache docker images
  21. uses: actions/cache@v2
  22. env:
  23. cache-name: joystream-node-docker
  24. with:
  25. path: ~/docker-images
  26. key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }}
  27. - name: Check if we have cached image
  28. continue-on-error: true
  29. run: |
  30. if [ -f ~/docker-images/joystream-node-docker-image.tar.gz ]; then
  31. docker load --input ~/docker-images/joystream-node-docker-image.tar.gz
  32. cp ~/docker-images/joystream-node-docker-image.tar.gz .
  33. fi
  34. - name: Check if we have pre-built image on Dockerhub
  35. continue-on-error: true
  36. run: |
  37. if ! [ -f joystream-node-docker-image.tar.gz ]; then
  38. docker pull joystream/node:${{ steps.compute_shasum.outputs.shasum }}
  39. docker image tag joystream/node:${{ steps.compute_shasum.outputs.shasum }} joystream/node:latest
  40. docker save --output joystream-node-docker-image.tar joystream/node:latest
  41. gzip joystream-node-docker-image.tar
  42. cp joystream-node-docker-image.tar.gz ~/docker-images/
  43. fi
  44. - name: Build new joystream/node image
  45. run: |
  46. if ! [ -f joystream-node-docker-image.tar.gz ]; then
  47. docker build . --file joystream-node.Dockerfile --tag joystream/node
  48. docker save --output joystream-node-docker-image.tar joystream/node
  49. gzip joystream-node-docker-image.tar
  50. cp joystream-node-docker-image.tar.gz ~/docker-images/
  51. echo "NEW_BUILD=true" >> $GITHUB_ENV
  52. fi
  53. - name: Save joystream/node image to Artifacts
  54. uses: actions/upload-artifact@v2
  55. with:
  56. name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
  57. path: joystream-node-docker-image.tar.gz
  58. - name: Login to DockerHub
  59. uses: docker/login-action@v1
  60. with:
  61. username: ${{ secrets.DOCKERHUB_USERNAME }}
  62. password: ${{ secrets.DOCKERHUB_PASSWORD }}
  63. if: env.NEW_BUILD
  64. - name: Publish new image to DockerHub
  65. run: |
  66. docker image tag joystream/node joystream/node:${{ steps.compute_shasum.outputs.shasum }}
  67. docker push joystream/node:${{ steps.compute_shasum.outputs.shasum }}
  68. if: env.NEW_BUILD