Copy updated files to the release folder and update file_list.py #21
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: Check and Copy Updated Files | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check-and-copy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.RENDER_KEY }} | |
- name: Set up SSH for Git | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.RENDER_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_rsa | |
- name: Parse File List from release/README.qmd | |
id: parse | |
run: | | |
# Extract the table section and parse the file paths | |
raw_file_list=$(awk '/\| name/ {f=1; next} /\|----/ {next} f && /\|/ {print $2}' software/release/README.qmd | tr -d ' ') | |
# Add the software/ prefix to each file path | |
echo "$raw_file_list" | sed 's/^/software\//' > file_list.txt | |
# Debugging output | |
echo "Files to monitor:" | |
cat file_list.txt | |
- name: Copy Files to Release Folder | |
run: | | |
mkdir -p software/release # Ensure the release folder exists | |
while read file; do | |
# Skip the config.py file | |
if [[ "$(basename $file)" == "config.py" ]]; then | |
echo "Skipping config.py" | |
continue | |
fi | |
# Copy the file, overwriting if it already exists | |
cp "$file" software/release/ # Overwrite files directly to the root of the release folder | |
done < file_list.txt | |
- name: List Files in Release Folder | |
run: | | |
echo "Files copied to the release folder:" | |
find software/release -type f | |
- name: Rename file_list.txt to file_list.py and add Python list | |
run: | | |
# Rename file_list.txt to file_list.py in the release folder | |
mv file_list.txt software/release/file_list.py | |
# Create Python list and add file paths to software/release/file_list.py | |
echo "file_list = [" > software/release/file_list.py | |
cat software/release/file_list.py | while read file; do | |
echo " '$file'," >> software/release/file_list.py | |
done | |
echo "]" >> software/release/file_list.py | |
- name: Commit and Push Changes | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
# Add, commit, and push changes | |
git add software/release/ | |
git commit -m "Copy updated files to the release folder and update file_list.py" | |
git push origin main |