Automatically add new mintages #9
Workflow file for this run
This file contains hidden or 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: Automatically add new mintages | |
| on: | |
| schedule: | |
| - cron: '0 0 1 12 *' # At 00:00 on December 1st every year | |
| workflow_dispatch: | |
| jobs: | |
| automatically-add-mintages: | |
| name: Automatically add new mintages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Open Coin Data | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: coinection/open-coin-data | |
| path: ocd | |
| - name: Set next year variable | |
| run: | | |
| NEXT_YEAR=$(($(date +%Y) + 1)) | |
| echo "NEXT_YEAR=$NEXT_YEAR" >> $GITHUB_ENV | |
| echo "BRANCH_NAME=add-mintages-$NEXT_YEAR" >> $GITHUB_ENV | |
| - name: Create or update branch | |
| run: | | |
| cd ./ocd | |
| git fetch --all | |
| if git rev-parse --verify origin/$BRANCH_NAME; then | |
| echo "Branch $BRANCH_NAME already exists in Coinection, checking out..." | |
| git checkout $BRANCH_NAME | |
| else | |
| echo "Branch $BRANCH_NAME does not exist in Coinection, creating new branch..." | |
| git checkout -b $BRANCH_NAME | |
| fi | |
| - name: Run Mintage Update Script | |
| run: | | |
| cd ./ocd/Scripts | |
| npm install | |
| npm run update | |
| - name: Commit and push changes to Open Coin Data | |
| run: | | |
| cd ./ocd | |
| if git diff --quiet; then | |
| echo "No changes detected in Open Coin Data. Exiting gracefully..." | |
| exit 0 | |
| else | |
| echo "Changes detected. Proceeding with commit and push..." | |
| fi | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "Coinection" | |
| git add . | |
| git commit -m "Add mintage data for $NEXT_YEAR" | |
| git push origin "$BRANCH_NAME" |