Skip to content

Export Extensions List #27

Export Extensions List

Export Extensions List #27

name: Export Extensions List
on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at 00:00 UTC
workflow_dispatch: # Allows manual trigger
jobs:
export:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
# Check out the current repository so that generate_extensions.sh is available.
- name: Checkout self repository
uses: actions/checkout@v3
# Get the latest commit hash of the raycast/extensions repository.
- name: Get latest commit hash from raycast/extensions
id: get_latest_commit
run: |
# Use git ls-remote to get the HEAD commit hash.
LATEST_COMMIT=$(git ls-remote https://github.com/raycast/extensions.git HEAD | awk '{print $1}')
echo "Latest commit hash: $LATEST_COMMIT"
echo "commit=$LATEST_COMMIT" >> "$GITHUB_OUTPUT"
# Restore (or later save) the cache for the raycast_extensions folder using the commit hash.
- name: Cache raycast extensions repository
uses: actions/cache@v3
with:
path: raycast_extensions
key: raycast-extensions-${{ steps.get_latest_commit.outputs.commit }}
# Either update an existing clone (cache hit) or clone afresh (cache miss).
- name: Update or clone raycast extensions repository
run: |
if [ -d "raycast_extensions" ]; then
echo "Cache hit. Updating existing clone..."
cd raycast_extensions
git fetch --all
git reset --hard origin/HEAD
else
echo "Cache miss. Cloning repository..."
git clone https://github.com/raycast/extensions.git raycast_extensions
fi
# Run the export script (assumed to be in the root of your repository).
- name: Run export script
run: |
cd raycast_extensions
chmod +x ../generate_extensions.sh
../generate_extensions.sh
# Copy the generated file to a temporary output folder.
- name: Copy generated file to output folder
run: |
mkdir -p out
cp raycast_extensions/extensions.txt out/extensions.txt
# Commit and push the file to an orphan branch named "extensions-list" in your repository.
- name: Commit and push extensions.txt to orphan branch
run: |
cd out
git init
git checkout -b extensions-list
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add extensions.txt
git commit -m "Update extensions list [skip ci]"
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push -f origin extensions-list