Skip to content

Build and publish docker extension #73

Build and publish docker extension

Build and publish docker extension #73

name: Build and publish docker extension
on:
workflow_run:
workflows: ["Publish container"]
types:
- completed
workflow_dispatch:
permissions:
contents: read
env:
REGISTRY: docker.io
IMAGE_NAME: headlamp/headlamp-docker-extension
jobs:
build_and_push_docker_extension:
name: Build docker extension
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 # v1.14.1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check out the repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Update docker image tags
run: |
lastTag=$(git tag --list --sort=version:refname 'v*' | tail -2 | head -1)
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1)
echo "replacing ${lastTag} with ${latestTag}"
sed -i "s/$lastTag/$latestTag/g" ./docker-extension/Dockerfile
sed -i "s/$lastTag/$latestTag/g" ./docker-extension/docker-compose.yml
- name: Bump headlamp version and push the docker image
run: |
user=${{github.actor}}
if [ -z $user ]; then
user=yolossn
fi
if [ "${{github.event_name}}" == "workflow_dispatch" ]; then
echo "Manual trigger so skipping git push"
else
git config --global user.name "$user"
git config --global user.email "[email protected]"
git diff
git add ./docker-extension/Dockerfile
git add ./docker-extension/docker-compose.yml
git status
lastTag=$(git tag --list --sort=version:refname 'v*' | tail -2 | head -1)
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1)
git commit --signoff -m "docker-ext: Bump Headlamp version from $lastTag to $latestTag"
git log -1
git push origin main
fi
- name: Build and Publish extension to DockerHub
run: |
docker buildx create --use
make docker-ext