|
| 1 | +name: Create and publish a Docker image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["*"] |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + IMAGE_NAME: ${{ github.repository }} |
| 10 | + ROS_DISTRO: humble |
| 11 | + BRANCH: master |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-and-push-release: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Set up Docker Buildx |
| 22 | + uses: docker/setup-buildx-action@v3 |
| 23 | + |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v5 |
| 26 | + |
| 27 | + - name: Log in to the Container registry |
| 28 | + uses: docker/login-action@v3 |
| 29 | + with: |
| 30 | + registry: ${{ env.REGISTRY }} |
| 31 | + username: ${{ github.actor }} |
| 32 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + |
| 34 | + - name: Docker meta |
| 35 | + id: meta |
| 36 | + uses: docker/metadata-action@v5 |
| 37 | + with: |
| 38 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_release |
| 39 | + tags: | |
| 40 | + type=ref,event=branch |
| 41 | + type=semver,pattern={{version}} |
| 42 | + type=semver,pattern={{major}}.{{minor}} |
| 43 | +
|
| 44 | + - name: Build and push Docker image |
| 45 | + uses: docker/build-push-action@v6 |
| 46 | + with: |
| 47 | + context: . |
| 48 | + push: true |
| 49 | + tags: ${{ steps.meta.outputs.tags }} |
| 50 | + labels: ${{ steps.meta.outputs.labels }} |
| 51 | + file: .docker/release/Dockerfile |
| 52 | + build-args: ROS_DISTRO=${{ env.ROS_DISTRO }} |
| 53 | + |
| 54 | + build-and-push-source: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + permissions: |
| 57 | + contents: read |
| 58 | + packages: write |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Set up Docker Buildx |
| 62 | + uses: docker/setup-buildx-action@v3 |
| 63 | + |
| 64 | + - name: Checkout repository |
| 65 | + uses: actions/checkout@v5 |
| 66 | + |
| 67 | + - name: Log in to the Container registry |
| 68 | + uses: docker/login-action@v3 |
| 69 | + with: |
| 70 | + registry: ${{ env.REGISTRY }} |
| 71 | + username: ${{ github.actor }} |
| 72 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Docker meta |
| 75 | + id: meta |
| 76 | + uses: docker/metadata-action@v5 |
| 77 | + with: |
| 78 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_source |
| 79 | + tags: | |
| 80 | + type=ref,event=branch |
| 81 | + type=semver,pattern={{version}} |
| 82 | + type=semver,pattern={{major}}.{{minor}} |
| 83 | +
|
| 84 | + - name: Build and push Docker image |
| 85 | + uses: docker/build-push-action@v6 |
| 86 | + with: |
| 87 | + context: . |
| 88 | + push: true |
| 89 | + tags: ${{ steps.meta.outputs.tags }} |
| 90 | + labels: ${{ steps.meta.outputs.labels }} |
| 91 | + file: .docker/source/Dockerfile |
| 92 | + build-args: | |
| 93 | + ROS_DISTRO=${{ env.ROS_DISTRO }} |
| 94 | + BRANCH=${{ env.BRANCH }} |
0 commit comments