Build and publish docker extension #66
This file contains 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: 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@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
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 | |