name: Docker on: workflow_dispatch: push: branches: - "main" pull_request: types: - opened - reopened - synchronize - ready_for_review concurrency: group: docker-${{ github.ref }} cancel-in-progress: true defaults: run: shell: bash env: FORCE_COLOR: 1 REGISTRY: ghcr.io IMAGE_NAME: mujocolab/mjlab permissions: id-token: write packages: write jobs: check_paths: runs-on: ubuntu-22.04 outputs: build: ${{ steps.filter.outputs.any }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - id: filter uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2 with: list-files: shell filters: | any: - ".github/workflows/docker.yml" - "Dockerfile" build: needs: check_paths if: ${{ needs.check_paths.outputs.build == 'true' }} runs-on: ubuntu-22.04 steps: - name: Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup Docker buildx uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 - name: Log into registry uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Docker metadata id: meta uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=raw,value=latest,enable={{is_default_branch}} - name: Build and push Docker image uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 with: context: . push: ${{ github.ref == 'refs/heads/main' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: | type=gha type=registry,ref=ghcr.io/mujocolab/mjlab/mjlab:buildcache cache-to: | type=gha,mode=max type=registry,ref=ghcr.io/mujocolab/mjlab/mjlab:buildcache,mode=max platforms: linux/amd64