Skip to content

Push

Push #211

name: Push
on:
workflow_dispatch:
workflow_run:
workflows: ["Build"]
types:
- completed
env:
DOCKER-CONTEXT: ./
DOCKER-FILE: ./Dockerfile
DOCKER-IMAGE: trainee
DOCKER-TAG: humble
jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}
steps:
- uses: actions/checkout@v4
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker image tag
run: echo "DOCKER_IMAGE_TAG=ghcr.io/$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')/${{ env.DOCKER-IMAGE }}:${{ env.DOCKER-TAG }}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v3
with:
context: ${{ env.DOCKER-CONTEXT }}
file: ${{ env.DOCKER-FILE }}
tags: ${{ env.DOCKER_IMAGE_TAG }}
build-args: USERNAME=runner
ssh: default=${{ env.SSH_AUTH_SOCK }}
no-cache: true
push: true