fix filename #18
Workflow file for this run
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 KEGG API for new records | |
on: | |
#schedule: | |
# - cron: '0 0 1 * *' # Runs at midnight on the 1st of every month | |
push: | |
branches: | |
- code-improvements | |
jobs: | |
check-api: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Get current date | |
id: date | |
run: | | |
echo "BRANCH_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Check API for new records | |
run: python kegg_pathways_completeness/bin/update_pathways_data/get_modules_list.py | |
- name: Check if new_modules.txt exists | |
id: check-file | |
run: | | |
if [[ -f "new_modules.txt" ]]; then | |
echo "file_exists=true" >> $GITHUB_ENV | |
else | |
echo "file_exists=false" >> $GITHUB_ENV | |
fi | |
- name: Add new modules info into existing and sort | |
if: env.file_exists == 'true' | |
run: | | |
cat kegg_pathways_completeness/pathways_data/all_pathways.txt pathways/all_pathways.txt | sort > kegg_pathways_completeness/pathways_data/all_pathways_sorted.txt | |
mv kegg_pathways_completeness/pathways_data/all_pathways_sorted.txt kegg_pathways_completeness/pathways_data/all_pathways.txt | |
cat kegg_pathways_completeness/pathways_data/all_pathways_class.txt pathways/all_pathways_class.txt | sort > kegg_pathways_completeness/pathways_data/all_pathways_class_sorted.txt | |
mv kegg_pathways_completeness/pathways_data/all_pathways_class_sorted.txt kegg_pathways_completeness/pathways_data/all_pathways_class.txt | |
cat kegg_pathways_completeness/pathways_data/all_pathways_names.txt pathways/all_pathways_names.txt | sort > kegg_pathways_completeness/pathways_data/all_pathways_names_sorted.txt | |
mv kegg_pathways_completeness/pathways_data/all_pathways_names_sorted.txt kegg_pathways_completeness/pathways_data/all_pathways_names.txt | |
- name: Regenerate graphs and move old to updates folder | |
if: env.file_exists == 'true' | |
run: | | |
python3 kegg_pathways_completeness/bin/make_graphs/make_graphs.py -i kegg_pathways_completeness/pathways_data/all_pathways.txt | |
mv kegg_pathways_completeness/graphs/graphs.pkl kegg_pathways_completeness/graphs/updates/graphs-{{ env.BRANCH_DATE }}.pkl | |
mv graphs.pkl kegg_pathways_completeness/graphs/graphs.pkl | |
- name: Generate plots for updates modules | |
if: env.file_exists == 'true' | |
run: | | |
python3 kegg_pathways_completeness/bin/make_graphs/get_dot.py -g kegg_pathways_completeness/graphs/graphs.pkl -l kegg_pathways_completeness/pathways_data/all_pathways.txt | |
python3 kegg_pathways_completeness/bin/make_graphs/plot.py -l kegg_pathways_completeness/pathways_data/all_pathways.txt | |
mv png dots kegg_pathways_completeness/graphs/ | |
- name: Count number of lines in all_pathways.txt | |
if: env.file_exists == 'true' | |
id: line_count | |
run: | | |
lines=$(wc -l < kegg_pathways_completeness/pathways_data/all_pathways.txt) | |
echo "line_count=$lines" >> $GITHUB_ENV | |
- name: Update README | |
if: env.file_exists == 'true' | |
run: | | |
sed -i "s/The current version of this tool has .* KEGG modules (updated .*)./The current version of this tool has ${line_count} KEGG modules (updated ${BRANCH_DATE})./" README.md | |
- name: Commit and push changes | |
if: env.file_exists == 'true' | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config pull.rebase false | |
git pull origin master --allow-unrelated-histories | |
git checkout -b changes-${{ env.BRANCH_DATE }} | |
git add kegg_pathways_completeness/pathways_data/all_pathways.txt | |
git add kegg_pathways_completeness/pathways_data/all_pathways_class.txt | |
git add kegg_pathways_completeness/pathways_data/all_pathways_name.txt | |
git add kegg_pathways_completeness/graphs/dots | |
git add kegg_pathways_completeness/graphs/png | |
git add kegg_pathways_completeness/graphs/graphs.pkl | |
git add README.md | |
git commit -m "Add updated files" | |
git push origin HEAD:changes-${{ env.BRANCH_DATE }} | |
- name: Create Pull Request | |
if: env.file_exists == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: changes-${{ env.BRANCH_DATE }} | |
base: master | |
title: "Automated update of new modules" | |
body: "This PR was created automatically by the GitHub Action." |