Improve swagger generation (#370) #288
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: Update Currencies | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
update-currencies: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
- name: Run currency fetch script | |
run: python .github/scripts/update_currencies.py | |
- name: Check for changes | |
id: check_changes | |
run: | | |
if [[ $(git status --porcelain) ]]; then | |
echo "Changes detected." | |
echo "changes=true" >> $GITHUB_ENV | |
else | |
echo "No changes detected." | |
echo "changes=false" >> $GITHUB_ENV | |
fi | |
- name: Delete existing update-currencies branch | |
run: | | |
if git show-ref --verify --quiet refs/heads/update-currencies; then | |
git branch -D update-currencies | |
echo "Deleted existing update-currencies branch." | |
else | |
echo "No existing update-currencies branch to delete." | |
fi | |
- name: Create new update-currencies branch | |
if: env.changes == 'true' | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Create a new branch | |
git checkout -b update-currencies | |
git add backend/internal/core/currencies/currencies.json | |
git commit -m "Update currencies.json" | |
# Fetch the latest changes from the remote | |
git fetch origin | |
# Attempt to rebase with the latest changes | |
if git show-ref --verify --quiet refs/remotes/origin/update-currencies; then | |
if ! git rebase origin/update-currencies; then | |
echo "Rebase conflicts occurred. Please resolve them manually." | |
echo "To resolve conflicts, check out the 'update-currencies' branch locally." | |
exit 1 | |
fi | |
else | |
echo "No existing remote branch 'update-currencies'. Skipping rebase." | |
fi | |
# Push the new branch to the remote | |
if ! git push --set-upstream origin update-currencies; then | |
echo "Push failed, trying to fetch and rebase again." | |
git fetch origin | |
if git show-ref --verify --quiet refs/remotes/origin/update-currencies; then | |
if ! git rebase origin/update-currencies; then | |
echo "Second rebase failed. Please resolve manually." | |
exit 1 | |
fi | |
else | |
echo "No existing remote branch 'update-currencies'. Skipping rebase." | |
fi | |
if ! git push --set-upstream origin update-currencies; then | |
echo "Second push failed. Please resolve manually." | |
exit 1 | |
fi | |
fi | |
# Create a pull request | |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-X POST \ | |
-d '{"title": "Update currencies", "head": "update-currencies", "base": "main"}' \ | |
https://api.github.com/repos/${{ github.repository }}/pulls | |
- name: Notify no changes | |
if: env.changes == 'false' | |
run: echo "Currencies up-to-date with API, skipping commit." |