From 77fdc996545903f149a7ddcf77ecc78eca22437f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eirik=20Kol=C3=A5s?= Date: Mon, 9 Oct 2023 18:04:20 +0200 Subject: [PATCH] added docker publish action --- .github/workflows/docker-publish.yml | 65 ++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..3068f887 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,65 @@ +name: Publish Docker image to ghcr + +on: + push: + branches: [ ros2 ] + workflow_dispatch: + + pull_request: + types: [opened, reopened] + branches: [ ros2 ] + +env: + REGISTRY: ghcr.io + REGISTRY_IMAGE: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ros_distro: + - rolling + - humble + - iron + + permissions: + contents: read + packages: write + + steps: + - name: Checkout own repository + uses: actions/checkout@v4 + + - name: Set up QEMU + if: matrix.architecture != 'linux/amd64' + uses: docker/setup-qemu-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}-${{ matrix.ros_distro }}:$(date +%s) + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/arm64,linux/amd64 \ No newline at end of file