From b59f5ca5782897ba48f17b83b20b4153f88290fd Mon Sep 17 00:00:00 2001 From: SoundDrill31 <84176052+sounddrill31@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:28:05 +0530 Subject: [PATCH] Check if repo exists/install if it doesn't exist --- .github/workflows/main.yml | 19 +++++++++++++++---- .github/workflows/selfhosted.yml | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 009d4930..60a75c15 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,10 +91,21 @@ jobs: # Download and configure 'repo'. - name: Configure the 'repo' environment run: | - mkdir "${HOME}/bin" - curl https://storage.googleapis.com/git-repo-downloads/repo >> "${HOME}/bin/repo" - chmod a+x "${HOME}/bin/repo" - sudo ln -sf "/home/${USER}/bin/repo" "/usr/bin/repo" + # Check if repo is already installed + if ! command -v repo >/dev/null 2>&1; then + echo "Repo not found. Installing now..." + # Create bin directory if it doesn't exist + mkdir -p ~/bin + # Download repo script + curl https://storage.googleapis.com/git-repo-downloads/repo >> ~/bin/repo + # Make repo script executable + chmod a+x ~/bin/repo + # Create symbolic link to /usr/bin/repo + sudo ln -sf "/home/$(whoami)/bin/repo" "/usr/bin/repo" + echo "Repo installation complete." + else + echo "Repo already installed." + fi continue-on-error: true # Generate 'git' credential in base of the workflow's author. diff --git a/.github/workflows/selfhosted.yml b/.github/workflows/selfhosted.yml index 3134643e..597671fc 100644 --- a/.github/workflows/selfhosted.yml +++ b/.github/workflows/selfhosted.yml @@ -131,10 +131,21 @@ jobs: # Download and configure 'repo'. - name: Configure the 'repo' environment run: | - mkdir "${HOME}/bin" - curl https://storage.googleapis.com/git-repo-downloads/repo >> "${HOME}/bin/repo" - chmod a+x "${HOME}/bin/repo" - sudo ln -sf "/home/${USER}/bin/repo" "/usr/bin/repo" + # Check if repo is already installed + if ! command -v repo >/dev/null 2>&1; then + echo "Repo not found. Installing now..." + # Create bin directory if it doesn't exist + mkdir -p ~/bin + # Download repo script + curl https://storage.googleapis.com/git-repo-downloads/repo >> ~/bin/repo + # Make repo script executable + chmod a+x ~/bin/repo + # Create symbolic link to /usr/bin/repo + sudo ln -sf "/home/$(whoami)/bin/repo" "/usr/bin/repo" + echo "Repo installation complete." + else + echo "Repo already installed." + fi continue-on-error: true # Generate 'git' credential in base of the workflow's author.