Build and push image #459
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 push image | |
on: | |
workflow_run: | |
workflows: ["Check code format"] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-image: | |
name: Build and push image | |
runs-on: self-hosted | |
outputs: | |
version: ${{ steps.build.version.outputs.version }} | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
# - name: Clear up some disk space | |
#run: | | |
# sudo rm -rf /usr/share/dotnet | |
#sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
#df -h | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
id: build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./build/docker/agent/Dockerfile | |
push: true | |
# tag 'latest' and version on push to main, otherwise use the commit hash | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
USERNAME=paf | |
USER_UID=1000 | |
USER_GID=1000 |