Update base images #207
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: Update base images | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'The branch to update, eg., main or 7.56.x (or 20221111 for che-incubator/jetbrains-editor-images)' | |
required: true | |
default: 'main' | |
repos: | |
description: 'List of repos to check for updates, comma-separated' | |
required: true | |
#TODO when adding/removing from this list, see lists below in this file and also in ../../utils/approvePRs.sh and ../../utils/check-branches.sh | |
default: ' | |
che-incubator/chectl, | |
che-incubator/che-code, | |
che-incubator/configbump, | |
che-incubator/jetbrains-editor-images, | |
che-incubator/kubernetes-image-puller, | |
che-incubator/kubernetes-image-puller-operator, | |
devfile/devworkspace-operator, | |
devfile/developer-images, | |
eclipse-che/che-dashboard, | |
eclipse-che/che-devfile-registry, | |
eclipse-che/che-machine-exec, | |
eclipse-che/che-operator, | |
eclipse-che/che-plugin-registry, | |
eclipse-che/che-server, | |
eclipse/che | |
' | |
schedule: | |
- cron: "0 0 * * 6" | |
jobs: | |
build: | |
name: Check | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
projects: | |
- { repo: "che-incubator/chectl", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "che-incubator/che-code", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "che-incubator/configbump", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "che-incubator/jetbrains-editor-images", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "che-incubator/kubernetes-image-puller", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "che-incubator/kubernetes-image-puller-operator", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "devfile/devworkspace-operator", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "devfile/developer-images", user: "CHE_INCUBATOR_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "eclipse-che/che-dashboard", user: "CHE_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "eclipse-che/che-devfile-registry", user: "CHE_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "eclipse-che/che-machine-exec", user: "CHE_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "eclipse-che/che-operator", user: "CHE_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 1 -f *Dockerfile --pr" } | |
- { repo: "eclipse-che/che-plugin-registry", user: "CHE_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "eclipse-che/che-server", user: "CHE_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
- { repo: "eclipse/che", user: "CHE_BOT_GITHUB_TOKEN", commandFlags: "-maxdepth 3 -f *Dockerfile --pr" } | |
steps: | |
- name: Set defaults (for use in crontab or workflow_dispatch) and check if we have a matching repo value | |
id: SETUP_REPOS | |
shell: bash | |
env: | |
DEFAULT_BRANCH: 'main' | |
DEFAULT_REPOS: ' | |
che-incubator/chectl, | |
che-incubator/che-code, | |
che-incubator/configbump, | |
che-incubator/jetbrains-editor-images, | |
che-incubator/kubernetes-image-puller, | |
che-incubator/kubernetes-image-puller-operator, | |
devfile/devworkspace-operator, | |
devfile/developer-images, | |
eclipse-che/che-dashboard, | |
eclipse-che/che-devfile-registry, | |
eclipse-che/che-machine-exec, | |
eclipse-che/che-operator, | |
eclipse-che/che-plugin-registry, | |
eclipse-che/che-server, | |
eclipse/che | |
' | |
run: | | |
echo "BRANCH=${{ github.event.inputs.branch || env.DEFAULT_BRANCH }}" >> $GITHUB_ENV | |
echo "REPOS=${{ github.event.inputs.repos || env.DEFAULT_REPOS }}" >> $GITHUB_ENV | |
echo GOT_REPO=false >> $GITHUB_OUTPUT | |
for r in $(echo ${{ github.event.inputs.repos || env.DEFAULT_REPOS }} | tr "," "\n"); do | |
if [[ $r == "${{ matrix.projects.repo }}" ]]; then | |
echo GOT_REPO=true >> $GITHUB_OUTPUT | |
break | |
fi | |
done | |
- name: "Checkout source code" | |
if: steps.SETUP_REPOS.outputs.GOT_REPO == 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ matrix.projects.repo }} | |
token: ${{ secrets[matrix.projects.user] }} | |
fetch-depth: 0 | |
- name: Login to registry.redhat.io | |
if: steps.SETUP_REPOS.outputs.GOT_REPO == 'true' | |
uses: docker/login-action@v2 | |
with: | |
registry: registry.redhat.io | |
username: ${{ secrets.CRW_BUILD_USER }} | |
password: ${{ secrets.CRW_BUILD_TOKEN }} | |
- name: Init | |
if: steps.SETUP_REPOS.outputs.GOT_REPO == 'true' | |
run: | | |
checkVersion() { | |
if [[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]]; then | |
# echo "[INFO] $3 version $2 >= $1, can proceed." | |
true | |
else | |
echo "[INFO] Installing $3 version >= $1 ..." | |
if [[ "$3" == "yq" ]]; then | |
pip install "$3" | |
else | |
sudo apt-get -y install "$3" | |
fi | |
fi | |
} | |
repos=$(echo ${{ env.REPOS }} | tr "," "\n") | |
for r in $repos; do | |
if [[ $r == "${{ matrix.projects.repo }}" ]]; then | |
# Install skopeo + yq | |
checkVersion 1.1 "$(skopeo --version | sed -e "s/skopeo version //")" skopeo | |
checkVersion 2.0 "$(yq --version | sed -e "s/yq //")" yq | |
pushd /tmp >/dev/null || exit 1 | |
curl -sSLO https://raw.githubusercontent.com/redhat-developer/codeready-workspaces/devspaces-3-rhel-8/product/updateBaseImages.sh | |
chmod +x updateBaseImages.sh | |
popd >/dev/null || exit 1 | |
export GITHUB_TOKEN=${{ secrets[matrix.projects.user] }} | |
git config --global user.name "Nick Boldt" | |
git config --global user.email "[email protected]" | |
echo "running job for ${{ matrix.projects.repo }}" | |
mkdir -p /tmp/${{ matrix.projects.repo }} | |
/tmp/updateBaseImages.sh -b ${{ env.BRANCH }} ${{ matrix.projects.commandFlags }} | tee /tmp/${{ matrix.projects.repo }}/log.txt | |
break | |
fi | |
done | |
if [[ ! -d /tmp/${{ matrix.projects.repo }} ]]; then | |
echo "SKIP running job for ${{ matrix.projects.repo }} - not included in $repos" | |
fi | |
- name: PR link | |
id: SETUP_PR_LINK | |
shell: bash | |
run: | | |
echo GOT_PR=false >> $GITHUB_OUTPUT | |
if [[ -f /tmp/${{ matrix.projects.repo }}/log.txt ]]; then | |
URL=$(grep "${{ matrix.projects.repo }}/pull/" /tmp/${{ matrix.projects.repo }}/log.txt 2>/dev/null || true) | |
if [[ $URL ]]; then | |
echo "$URL" | |
echo "PR_URL=\"$URL\"" >> $GITHUB_ENV | |
echo GOT_PR=true >> $GITHUB_OUTPUT | |
fi | |
fi |