push-containers.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. name: Build and Push prebuilt tools container
  2. on:
  3. push:
  4. paths:
  5. - 'tools/**'
  6. - '.github/workflows/build-tools.yml'
  7. - '.github/workflows/push-containers.yml'
  8. - '.github/workflows/Dockerfile.tools'
  9. permissions:
  10. contents: read
  11. jobs:
  12. build-linux-buildbot:
  13. name: Build tools with buildbot container
  14. uses: ./.github/workflows/build-tools.yml
  15. with:
  16. generate_prebuilt_artifacts: true
  17. push-tools-container:
  18. needs: build-linux-buildbot
  19. name: Push prebuilt tools container
  20. runs-on: ubuntu-latest
  21. permissions:
  22. contents: read
  23. packages: write
  24. steps:
  25. - name: Set lower case owner name
  26. env:
  27. OWNER: ${{ github.repository_owner }}
  28. run: |
  29. echo "OWNER_LC=${OWNER,,}" >> "$GITHUB_ENV"
  30. # Per branch tools container tag
  31. # By default stick to latest
  32. # For official test targetting openwrt stable branch
  33. # Get the branch or parse the tag and push dedicated tools containers
  34. # Any branch that will match this pattern openwrt-[0-9][0-9].[0-9][0-9]
  35. # will refresh the tools container with the matching tag.
  36. # (example branch openwrt-22.03 -> tools:openwrt-22.03)
  37. # (example branch openwrt-22.03-test -> tools:openwrt-22.03)
  38. - name: Determine tools container tag
  39. run: |
  40. CONTAINER_TAG=latest
  41. if [ ${{ github.ref_type }} == "branch" ]; then
  42. if echo "${{ github.ref_name }}" | grep -q -E 'openwrt-[0-9][0-9]\.[0-9][0-9]'; then
  43. CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\).*/\1/')"
  44. fi
  45. elif [ ${{ github.ref_type }} == "tag" ]; then
  46. if echo "${{ github.ref_name }}" | grep -q -E 'v[0-9][0-9]\.[0-9][0-9]\..+'; then
  47. CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
  48. fi
  49. fi
  50. echo "Tools container to push tools:$CONTAINER_TAG"
  51. echo "CONTAINER_TAG=$CONTAINER_TAG" >> "$GITHUB_ENV"
  52. - name: Checkout
  53. uses: actions/checkout@v3
  54. with:
  55. path: 'openwrt'
  56. - name: Download prebuilt tools from build job
  57. uses: actions/download-artifact@v3
  58. with:
  59. name: linux-buildbot-prebuilt-tools
  60. path: openwrt
  61. - name: Login to GitHub Container Registry
  62. uses: docker/login-action@v2
  63. with:
  64. registry: ghcr.io
  65. username: ${{ github.actor }}
  66. password: ${{ secrets.GITHUB_TOKEN }}
  67. - name: Build and push
  68. uses: docker/build-push-action@v3
  69. with:
  70. context: openwrt
  71. push: true
  72. tags: ghcr.io/${{ env.OWNER_LC }}/tools:${{ env.CONTAINER_TAG }}
  73. file: openwrt/.github/workflows/Dockerfile.tools