Sun Jul 30 12:17:18 PM UTC 2023 #44
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: Deploy to gh-pages and Create Repos | |
on: | |
push: | |
branches: | |
- master # Adjust the branch name to the branch you want to trigger the deployment | |
jobs: | |
deploy_and_create_repos: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Deploy to gh-pages | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
git branch -a # Optional: Display branches for debugging purposes | |
git checkout gh-pages || git checkout --orphan gh-pages | |
git add . | |
git commit -m 'Update gh-pages' | |
git push origin gh-pages -f | |
- name: Create Repos | |
run: | | |
# hymnals=$(cat hymnals.yaml | grep -o "'[^\']*'" | sed "s/'//g") | |
cat hymnals.yaml | grep -o "'[^\']*'" | sed "s/'//g" | while read -r hymnal; do | |
echo "=>$hymnal" | |
# REPO_NAME=$(echo "$hymnal" | sed 's/-/_/g') # Replace hyphens with underscores for valid repository names | |
REPO_NAME="$hymnal" | |
ORG_NAME=${{ github.repository_owner }} | |
# Check if the repository exists | |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/$ORG_NAME/$REPO_NAME") | |
if [ "$RESPONSE" -eq 200 ]; then | |
# ## Repository exists, delete it using GitHub API | |
# curl -X DELETE \ | |
# -H "Authorization: token ${{ secrets.CREATE_AH_REPOS }}" \ | |
# "https://api.github.com/repos/$ORG_NAME/$REPO_NAME" | |
continue | |
fi | |
# Create the new repository using GitHub API | |
curl -X POST \ | |
-H "Authorization: token ${{ secrets.CREATE_AH_REPOS }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"name\":\"$REPO_NAME\", \"description\":\"$REPO_NAME in v4 format\", \"private\":false,\"has_issues\":true,\"has_projects\":true,\"has_wiki\":true}" \ | |
"https://api.github.com/orgs/$ORG_NAME/repos" | |
#cd /tmp | |
#csycmsLink=$(echo "$REPO_NAME"|sed -e 's/v4$/csycms/') | |
#echo $csycmsLink | |
##git clone "[email protected]:adventHymnals/$csycmsLink.git" | |
##git clone "https://username:${{ secrets.CREATE_AH_REPOS }}@github.com/$ORG_NAME/$csycmsLink.git" | |
#git clone "https://github.com/adventHymnals/$csycmsLink.git" | |
#cd "$csycmsLink" | |
#ls | |
#ls -lha | |
#git remote set-url origin "[email protected]:adventHymnals/$REPO_NAME.git" | |
#git config --unset-all http.https://github.com/.extraheader | |
#git push "https://username:${{ secrets.CREATE_AH_REPOS }}@github.com/$ORG_NAME/$REPO_NAME.git" master | |
done | |
REPO_NAME="advent_hymnals_v4" | |
ORG_NAME=${{ github.repository_owner }} | |
# Check if the repository exists | |
#RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/$ORG_NAME/$REPO_NAME") | |
curl -X POST \ | |
-H "Authorization: token ${{ secrets.CREATE_AH_REPOS }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"name\":\"$REPO_NAME\", \"description\":\"$REPO_NAME in v4 format\", \"private\":false,\"has_issues\":true,\"has_projects\":true,\"has_wiki\":true}" \ | |
"https://api.github.com/orgs/$ORG_NAME/repos" | |