Skip to content

Update Dockerfile

Update Dockerfile #15

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build and publish Docker image
on:
workflow_dispatch:
pull_request:
branches: ["main","devel"]
types: [closed]
paths:
- '.github/workflows/build-and-publish-image.yml'
- 'Dockerfile'
- 'reinstall-cmake.sh'
- 'VERSION'
env:
REGISTRY: ghcr.io
IMAGE_NAME: startrooper08/r-dev-env
jobs:
build-and-push-image:
if: ${{github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true}}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version number
run: |
VER=$(cat VERSION)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{ env.VERSION }}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
build-args: |
CONTAINER_VERSION=${{ env.VERSION }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
- name: Build and push ARM based Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm.${{ github.ref_name }}
build-args: |
CONTAINER_VERSION=${{ env.VERSION }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/arm64