Skip to content

Get Repositories

Get Repositories #92

Workflow file for this run

name: Get Repositories
on:
workflow_dispatch:
jobs:
Install_gh_CLI:
runs-on: ubuntu-latest
steps:
- name: Install gh CLI
run: |
# Install gh CLI
sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
login:
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh auth login --with-token <<<"${GH_TOKEN}"
- name: Checkout Repository
uses: actions/checkout@v4
## - name: Get Repository Names
## id: get-repos
##run: |
##gh api --paginate '/users/Rafi98/repos' --jq '.[].full_name' > repositories.txt
#gh api --paginate '/Rafi98/GH_TASK3' --jq '.[].full_name' > repositories.txt
# Replace '/Rafi98/GH_TASK3' with the appropriate endpoint for organization repositories if needed
##- name: Display Repository Names
##run: |
##cat repositories.txt
- name: Get Repository Topics from README.md
id: get-topics
run: |
topics=$(gh api repos/Rafi98/GH_TASK3/topics --jq '.names[]')
echo "Repository Topics: $topics"
- name: Print Topics from topics.txt
run: |
cat topics.txt
- name: Install gh CLI
run: |
# Install gh CLI
sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
##- name: Fetch Repository List
##id: fetch-repos
##run: |
##gh api --paginate '/users/Rafi98/repos' --jq '.[].full_name' > repositories.txt
##- name: Read Repository List
##id: read-repos
##run: |
##while IFS= read -r repo; do
##echo "$repo"
##done < repositories.txt
- name: Extract Topics content from README.md
run: |
topics=$(grep -oE '^#+\s+\S+' README.md | sed 's/^#* //')
echo "Topics found in README.md:"
echo "$topics"
run_script:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Execute Permission
run: chmod +x update_topics.sh
- name: List Files
run: ls
- name: Print Topics from topics.txt
run: |
cat topics.txt
- name: Pull Changes
run: git pull origin main
- name: Execute Shell Script
run: |
./update_topics.sh "AWS" "topics.txt" #Add the text to the topics.txt file
git config --global user.name "Rafi98"
git config --global user.email "s.mdrafi98@gmail.com"
#git add .github/workflows/topics.txt
git add .
git commit -m "Update topics.txt"
git push
- name: Print Topics from topics.txt
run: |
cat topics.txt
- name: Checkout Repository
uses: actions/checkout@v2
- name: Pull Changes
run: git pull origin main
- name: Read topics.txt
id: read-topics
run: |
## echo "::set-output name=topics::$(cat topics.txt)"
#echo "$(cat topics.txt)" > topics_output.txt
#echo "TOPICS_FILE=topics.txt" >> $GITHUB_ENV
topics_content=$(cat topics.txt)
#echo "TOPICS_CONTENT=$topics_content" >> $GITHUB_ENV
- name: Update README.md
run: |
##echo "# Topics" >> README.md
##echo "${{ steps.read-topics.outputs.topics }}" >> README.md
###echo "${{ env.TOPICS_CONTENT }}" >> README.md
echo "${topics_content}" >> README.md
- name: Commit and Push Changes
run: |
git config --global user.name "Rafi98"
git config --global user.email "s.mdrafi98@gmail.com"
git add .
git commit -m "Update README.md with topics.txt content"
git push
## - name: Compare Topics
## id: compare-topics
##run: |
##topics_txt=$(echo "${{ steps.read-topics.outputs.stdout }}")
##readme_topics=$(echo "${{ steps.extract-readme-topics.outputs.stdout }}")
## newly_added_topics=$(comm -13 <(echo "$readme_topics" | sort) <(echo "$topics_txt" | sort))
##echo "Newly added topics from topics.txt: $newly_added_topics"
##- name: Add New Topics to README.md
##run: |
## Replace <new_topics> with the actual new topics
##echo -e "\n\n## Newly Added Topics\n CLOUD - AWS " >> README.md
##- name: Commit and Push Changes
#uses: actions/checkout@v4
##run: |
##git config --local user.email "s.mdrafi98@gmail.com"
##git config --local user.name "Rafi98"
##git add README.md
##git commit -m "Add newly added topics to README.md"
##- name: Push Changes
#uses: ad-m/github-push-action@v0.6.0
##uses: actions/checkout@v4
##with:
##github_token: ${{ secrets.GH_TOKEN }}
##branch: main
#repository: https://github.com/Rafi98/GH_TASK3.git