Skip to content

mso5000: forgot to commit patch_mounts #13

mso5000: forgot to commit patch_mounts

mso5000: forgot to commit patch_mounts #13

Workflow file for this run

name: Release Container
on:
push:
branches:
- main
jobs:
next-version:
runs-on: rehosting-arc
outputs:
v-version: ${{ steps.version.outputs.v-version }}
matrix: ${{ steps.filter_dockerfiles.outputs.matrix }}
unchanged_matrix: ${{ steps.filter_dockerfiles.outputs.unchanged_matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Setup runner
run: |
sudo apt-get update;
sudo apt-get install -yy curl jq git
- name: Get next version
uses: reecetech/version-increment@2024.4.4
id: version
with:
use_api: true
- name: Find all the dockerfiles
id: find_dockerfiles
run: |
OUTPUTS=$(find . -type f -name "Dockerfile.*" | xargs -i{} basename {} | cut -d. -f2 | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo matrix=${OUTPUTS} >> $GITHUB_OUTPUT
- name: Filter dockerfiles to changed only
id: filter_dockerfiles
run: |
set -e
if git tag --list | grep .; then
BASE=$(git describe --tags --abbrev=0)
else
BASE=$(git rev-list --max-parents=0 HEAD)
fi
echo "Base for diff: $BASE"
CHANGED_TARGETS=()
for target in $(echo '${{ steps.find_dockerfiles.outputs.matrix }}' | jq -r '.[]'); do
DOCKERFILE_PATH=$(find . -type f -name "Dockerfile.${target}" | head -n 1)
DOCKERFILE_DIR=$(dirname "$DOCKERFILE_PATH")
if ! git diff --quiet "$BASE"..HEAD -- "$DOCKERFILE_DIR"; then
CHANGED_TARGETS+=("$target")
fi
done
MATRIX=$(printf '%s\n' "${CHANGED_TARGETS[@]}" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo matrix=${MATRIX} >> $GITHUB_OUTPUT
# Also output unchanged targets
UNCHANGED_TARGETS=()
for target in $(echo '${{ steps.find_dockerfiles.outputs.matrix }}' | jq -r '.[]'); do
if [[ ! " ${CHANGED_TARGETS[@]} " =~ " $target " ]]; then
UNCHANGED_TARGETS+=("$target")
fi
done
UNCHANGED_MATRIX=$(printf '%s\n' "${UNCHANGED_TARGETS[@]}" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo unchanged_matrix=${UNCHANGED_MATRIX} >> $GITHUB_OUTPUT
build_images:
runs-on: rehosting-arc
needs: [next-version]
if: needs.next-version.outputs.matrix != '[]'
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.next-version.outputs.matrix) }}
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: rehosting
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Trust Harbor's self-signed certificate
run: |
echo "Fetching certificate from ${{ secrets.REHOSTING_ARC_REGISTRY }}"
openssl s_client -showcerts -connect ${{ secrets.REHOSTING_ARC_REGISTRY }}:443 < /dev/null 2>/dev/null | openssl x509 -outform PEM | sudo tee /usr/local/share/ca-certificates/harbor.crt > /dev/null
sudo update-ca-certificates
- name: Log in to Rehosting Arc Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REHOSTING_ARC_REGISTRY }}
username: ${{ secrets.REHOSTING_ARC_REGISTRY_USER }}
password: ${{ secrets.REHOSTING_ARC_REGISTRY_PASSWORD }}
- name: Setup runner
run: |
sudo apt-get update;
sudo apt-get install -yy curl jq git
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:master
network=host
buildkitd-config-inline: |
[registry."${{ secrets.REHOSTING_ARC_REGISTRY }}"]
insecure = true
http = true
- name: Generate name from file
id: generate_fname
run: |
DOCKERFILE_PATH=$(find . -type f -name "Dockerfile.${{ matrix.target }}" | head -n 1)
DOCKERFILE_DIR=$(dirname "$DOCKERFILE_PATH")
DOCKERFILE_FILE=$(basename "$DOCKERFILE_PATH")
echo "dir=$DOCKERFILE_DIR" >> $GITHUB_OUTPUT
echo "file=$DOCKERFILE_FILE" >> $GITHUB_OUTPUT
- name: Build Docker image for ${{ matrix.target }}
uses: docker/build-push-action@v6.3.0
with:
context: ${{ steps.generate_fname.outputs.dir }}
file: ${{ steps.generate_fname.outputs.dir }}/${{ steps.generate_fname.outputs.file }}
push: true
target: run
build-args: |
REGISTRY=${{ secrets.REHOSTING_ARC_REGISTRY }}/proxy
cache-from: |
type=registry,ref=${{ secrets.REHOSTING_ARC_REGISTRY }}/${{ github.repository }}:${{ matrix.target }}_cache,mode=max
cache-to: |
type=registry,ref=${{ secrets.REHOSTING_ARC_REGISTRY }}/${{ github.repository }}:${{ matrix.target }}_cache,mode=max
tags: |
${{ github.repository }}:${{ matrix.target }}
${{ github.repository }}:${{ matrix.target }}_latest
${{ github.repository }}:${{ matrix.target }}_${{ needs.next-version.outputs.v-version }}
retag_unchanged_images:
runs-on: rehosting-arc
needs: [next-version]
if: needs.next-version.outputs.unchanged_matrix != '[]'
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.next-version.outputs.unchanged_matrix) }}
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: rehosting
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Pull previous image
run: |
if docker pull ${{ github.repository }}:${{ matrix.target }}; then
echo "Pulled previous image for ${{ matrix.target }}"
else
echo "No previous image found for ${{ matrix.target }}"
exit 1
fi
- name: Tag with new version
run: |
docker tag ${{ github.repository }}:${{ matrix.target }} ${{ github.repository }}:${{ matrix.target }}_${{ needs.next-version.outputs.v-version }}
- name: Push new tag
run: |
docker push ${{ github.repository }}:${{ matrix.target }}_${{ needs.next-version.outputs.v-version }}
update:
needs: [next-version, build_images, retag_unchanged_images]
if: always()
runs-on: rehosting-arc
steps:
- name: Create release
id: create_release
uses: softprops/action-gh-release@v2.3.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.next-version.outputs.v-version}}
name: Release ${{ needs.next-version.outputs.v-version }} ${{ github.ref }}
body: |
Release ${{ needs.next-version.outputs.v-version }} @${{ github.ref }}
Contains the following rehostings: ${{ fromJSON(needs.next-version.outputs.matrix) }}
draft: false
generate_release_notes: true