|
| 1 | +name: Fetch Meetups |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "0 0 * * *" # Runs every day at 00:00 UTC time |
| 7 | + |
| 8 | +permissions: |
| 9 | + pull-requests: write |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + fetch: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - name: Set up Ruby |
| 18 | + |
| 19 | + uses: ruby/setup-ruby@v1 |
| 20 | + with: |
| 21 | + bundler-cache: true |
| 22 | + |
| 23 | + - name: Check for new Meetups |
| 24 | + run: bundle exec rake fetch_meetups |
| 25 | + |
| 26 | + - name: Verify Meetups Data |
| 27 | + run: bundle exec rake verify_meetups |
| 28 | + |
| 29 | + - name: Set up the formatted date, branch name and PR title |
| 30 | + run: | |
| 31 | + echo "FORMATTED_DATE=$(date +'%B %d, %Y')" >> $GITHUB_ENV |
| 32 | + echo "BRANCH_TO_MERGE=new-meetups-$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 33 | + echo "PULL_REQUEST_TITLE=$(cat ./pull_request_title.txt)" >> $GITHUB_ENV |
| 34 | +
|
| 35 | + - name: Check if there are any new meetups |
| 36 | + run: | |
| 37 | + if [[ -n $(git diff --name-only _data/meetups.yml) ]]; then |
| 38 | + echo "NEW_MEETUPS=true" >> $GITHUB_ENV |
| 39 | + else |
| 40 | + echo "NEW_MEETUPS=false" >> $GITHUB_ENV |
| 41 | + fi |
| 42 | +
|
| 43 | + - name: Commit New Meetups |
| 44 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 45 | + if: ${{ env.NEW_MEETUPS == 'true' }} |
| 46 | + with: |
| 47 | + # Optional. Commit message for the created commit. |
| 48 | + # Defaults to "Apply automatic changes" |
| 49 | + commit_message: ${{ env.PULL_REQUEST_TITLE }} |
| 50 | + |
| 51 | + # Optional. Local and remote branch name where commit is going to be pushed |
| 52 | + # to. Defaults to the current branch. |
| 53 | + # You might need to set `create_branch: true` if the branch does not exist. |
| 54 | + branch: ${{ env.BRANCH_TO_MERGE }} |
| 55 | + |
| 56 | + # Optional. Options used by `git-commit`. |
| 57 | + # See https://git-scm.com/docs/git-commit#_options |
| 58 | + # commit_options: '--no-verify --signoff' |
| 59 | + |
| 60 | + # Optional glob pattern of files which should be added to the commit |
| 61 | + # Defaults to all (.) |
| 62 | + # See the `pathspec`-documentation for git |
| 63 | + # - https://git-scm.com/docs/git-add#Documentation/git-add.txt-ltpathspecgt82308203 |
| 64 | + # - https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec |
| 65 | + file_pattern: '_data/*.yml' |
| 66 | + |
| 67 | + # Optional. Local file path to the repository. |
| 68 | + # Defaults to the root of the repository. |
| 69 | + # repository: . |
| 70 | + |
| 71 | + # Optional commit user and author settings |
| 72 | + # commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]" |
| 73 | + # commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com" |
| 74 | + # commit_author: Author <actions@github.com> # defaults to "username <username@users.noreply.github.com>", where "username" belongs to the author of the commit that triggered the run |
| 75 | + |
| 76 | + # Optional. Tag name being created in the local repository and |
| 77 | + # pushed to remote repository and defined branch. |
| 78 | + # tagging_message: 'v1.0.0' |
| 79 | + |
| 80 | + # Optional. Option used by `git-status` to determine if the repository is |
| 81 | + # dirty. See https://git-scm.com/docs/git-status#_options |
| 82 | + status_options: '--untracked-files=no' |
| 83 | + |
| 84 | + # Optional. Options used by `git-add`. |
| 85 | + # See https://git-scm.com/docs/git-add#_options |
| 86 | + # add_options: '-u' |
| 87 | + |
| 88 | + # Optional. Options used by `git-push`. |
| 89 | + # See https://git-scm.com/docs/git-push#_options |
| 90 | + # push_options: '--force' |
| 91 | + |
| 92 | + # Optional. Disable dirty check and always try to create a commit and push |
| 93 | + # skip_dirty_check: true |
| 94 | + |
| 95 | + # Optional. Skip internal call to `git fetch` |
| 96 | + # skip_fetch: true |
| 97 | + |
| 98 | + # Optional. Skip internal call to `git checkout` |
| 99 | + # skip_checkout: true |
| 100 | + |
| 101 | + # Optional. Prevents the shell from expanding filenames. |
| 102 | + # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html |
| 103 | + # disable_globbing: true |
| 104 | + |
| 105 | + # Optional. Create given branch name in local and remote repository. |
| 106 | + create_branch: true |
| 107 | + |
| 108 | + - name: Create Pull Request |
| 109 | + if: ${{ env.NEW_MEETUPS == 'true' }} |
| 110 | + run: gh pr create -B main -H ${{ env.BRANCH_TO_MERGE }} --title "${{ env.PULL_REQUEST_TITLE }}" --body-file "./new_meetups.md" |
| 111 | + env: |
| 112 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments