Refactor Devcontainer Dockerfile (Root User/Bind Mounts) and Restores GitHub Actions Workflows #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Image CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| # ensure that version tags also trigger a build, naming convention is `vX.Y.Z` | |
| # make sure the naming convention is followed in tags. | |
| tags: | |
| - "v*" | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: # set the ROS distribution to be used in the devcontainer, e.g. humble or iron | |
| ROS_DISTRO: humble | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Git Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 1 | |
| # log in to GitHub Container Registry with correct permission | |
| - name: Docker Login GHCR | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # create a docker image name from the github repository name, ensuring lower case and no disallowed characters | |
| - name: create docker image name from github name | |
| id: docker-image-name | |
| run: | | |
| repo_name=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' | tr '. ' '-') | |
| echo "image_name=$repo_name" >> $GITHUB_OUTPUT | |
| # set the relevant docker tags and labels | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| # list of Docker images to use as base name for tags | |
| labels: | | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| org.opencontainers.image.creator=${{ github.repository_owner }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} | |
| org.opencontainers.image.version=${{ github.ref_name }} | |
| images: | | |
| ghcr.io/${{ steps.docker-image-name.outputs.image_name }} | |
| flavor: | | |
| latest=auto | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=ref,event=branch | |
| - name: setup buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and Push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./.devcontainer/Dockerfile | |
| platforms: linux/amd64 # add other platforms if needed | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| target: final | |
| build-args: | | |
| BASE_IMAGE=ros:${{ env.ROS_DISTRO }} | |
| GIT_REPO_VERSION=${{ github.ref_name }} | |
| GIT_REPO_VERSION_DATE=${{ github.event.head_commit.timestamp }} |