diff --git a/.github/workflows/announce-calls.yml b/.github/workflows/announce-calls.yml index bc7d27a..5f6bd52 100644 --- a/.github/workflows/announce-calls.yml +++ b/.github/workflows/announce-calls.yml @@ -5,23 +5,25 @@ on: - cron: '0 9 8-14 * *' jobs: - announce: + build-message: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - ssh-key: ${{ secrets.MICROBLOG_DEPLOY_KEY }} - - name: Configure Git. - run: | - git config --global user.name 'farmOS' - git config --global user.email 'noreply@farmOS.org' # We use `date +\%u` below in combination with the schedule cron rules # above to ensure these only run on the days they are meant to. - - name: Announce calls + - name: Build message run: | TZ=UTC DAY=$(date +\%u) case "${DAY}" in - 3) git commit --allow-empty -m 'The #farmOS monthly community call is today at 2pm Eastern. All are welcome! https://farmos.org/community/monthly-call/' ;; + 3) echo "MESSAGE=The #farmOS monthly community call is today at 2pm Eastern. All are welcome! https://farmos.org/community/monthly-call/" >> $GITHUB_ENV ;; esac - git push origin main + outputs: + message: ${{ env.MESSAGE }} + announce-call: + uses: ./.github/workflows/create-message.yml + needs: + - build-message + if: ${{ needs.build-message.outputs.message }} + with: + message: ${{ needs.build-message.outputs.message }} + secrets: inherit diff --git a/.github/workflows/create-message.yml b/.github/workflows/create-message.yml new file mode 100644 index 0000000..d249fd2 --- /dev/null +++ b/.github/workflows/create-message.yml @@ -0,0 +1,37 @@ +name: Create message +on: + workflow_call: + inputs: + message: + type: string + required: true + secrets: + MICROBLOG_DEPLOY_KEY: + required: true + workflow_dispatch: + inputs: + message: + description: 'Message to announce' + type: string + required: true + +jobs: + create-message: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + # Hard-code the repository. This is needed when this workflow is + # triggered using workflow_call from other repositories. + repository: farmOS/farmOS-microblog + ssh-key: ${{ secrets.MICROBLOG_DEPLOY_KEY }} + - name: Configure Git. + run: | + git config --global user.name 'farmOS' + git config --global user.email 'noreply@farmOS.org' + - name: Commit/push to farmOS-microblog. + run: | + git commit --allow-empty --cleanup=whitespace -F- << MESSAGE + ${{ inputs.message }} + MESSAGE + git push origin main diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 149762f..0796811 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,7 +8,10 @@ jobs: publish: runs-on: ubuntu-latest steps: + - name: Echo message + run: echo ${{ github.event.head_commit.message }} - name: Mastodon + if: github.repository == 'farmOS/farmOS-microblog' uses: cbrgm/mastodon-github-action@6cffb7d449201bf36a60589de7a76e18ee226043 with: message: ${{ github.event.head_commit.message }}