diff --git a/.azure/scripts/push-info-to-gh-secrets.sh b/.azure/scripts/push-info-to-gh-secrets.sh index 3758d648..c4a5db9e 100755 --- a/.azure/scripts/push-info-to-gh-secrets.sh +++ b/.azure/scripts/push-info-to-gh-secrets.sh @@ -7,6 +7,27 @@ set -euo pipefail # deployed managed identity and sets them as GitHub repository secrets. # ----------------------------------------------------------------------------- +# --- Parse command line arguments --- +CI_MODE=false +while [[ $# -gt 0 ]]; do + case $1 in + --ci) + CI_MODE=true + shift + ;; + -h|--help) + echo "Usage: $0 [--ci]" + echo " --ci Skip GitHub CLI authentication check (for CI/CD environments)" + exit 0 + ;; + *) + echo "Unknown option: $1" + echo "Use --help for usage information" + exit 1 + ;; + esac +done + # --- Configuration (update these to match your setup) --- GITHUB_OWNER="MaxDac" GITHUB_REPO="Privee" @@ -29,9 +50,13 @@ if ! command -v gh &> /dev/null; then exit 1 fi -if ! gh auth status > /dev/null 2>&1; then - echo "ERROR: You are not authenticated with GitHub CLI. Please run 'gh auth login'." - exit 1 +if ! $CI_MODE; then + if ! gh auth status > /dev/null 2>&1; then + echo "ERROR: You are not authenticated with GitHub CLI. Please run 'gh auth login'." + exit 1 + fi +else + echo "✓ Running in CI mode - skipping GitHub CLI authentication check" fi echo "✓ Prerequisites met" diff --git a/.github/workflows/azure-provision.yml b/.github/workflows/azure-provision.yml index b3ebcc79..9010784c 100644 --- a/.github/workflows/azure-provision.yml +++ b/.github/workflows/azure-provision.yml @@ -72,9 +72,17 @@ jobs: run: | bash ./.azure/scripts/set-secrets-to-dev-kv.sh + - name: Authenticate GitHub CLI + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh auth login --with-token <<<"$GITHUB_TOKEN" + - name: Push Azure credentials to GitHub secrets + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - bash ./.azure/scripts/push-info-to-gh-secrets.sh + bash ./.azure/scripts/push-info-to-gh-secrets.sh --ci - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3