Skip to content

373 unstuck behavior #558

373 unstuck behavior

373 unstuck behavior #558

Workflow file for this run

name: Build and push image
on:
pull_request:
branches:
- "main"
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: Create cache directory
run: |
mkdir -p ./.buildx-cache/cache
mkdir ./.buildx-cache/cache-new
mkdir ./.buildx-cache/cache/test
mkdir ./.buildx-cache/cache/latest
mkdir ./.buildx-cache/cache-new/test
mkdir ./.buildx-cache/cache-new/latest
- name: Test build
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: ./build/docker/agent/Dockerfile
load: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:test
cache-from: type=local,src=./.buildx-cache/cache/test/
cache-to: type=local,dest=./.buildx-cache/cache-new/test/,mode=max
build-args: |
USERNAME=paf
USER_UID=1000
USER_GID=1000
- name: Build and push Docker image
id: build
if: github.event_name != 'pull_request'
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=local,src=./.buildx-cache/cache/latest/
cache-to: type=local,dest=./.buildx-cache/cache-new/latest/,mode=max
build-args: |
USERNAME=paf
USER_UID=1000
USER_GID=1000
- name: Save PR ID
if: github.event_name == 'pull_request'
env:
PR_ID: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_ID > ./pr/pr_id
- name: Upload PR ID
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: pr_id
path: pr/
retention-days: 1
- name: Clean up cache
run: |
rm -rf ./.buildx-cache/cache/test
rm -rf ./.buildx-cache/cache/latest
mv ./.buildx-cache/cache-new ./.buildx-cache/cache