From 2661f5fe5fb10cde7c871ccbe67440e0d7869487 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Sun, 20 Nov 2022 13:22:30 -0800 Subject: [PATCH 1/4] Add create-message workflow to further automate the microblog. --- .github/workflows/announce-calls.yml | 24 ++++++++++--------- .github/workflows/create-message.yml | 35 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/create-message.yml 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..21a0ac0 --- /dev/null +++ b/.github/workflows/create-message.yml @@ -0,0 +1,35 @@ +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 -m '${{ inputs.message }}' + git push origin main From 7387854e16de64857d8ae5172b80f6cc9cebf539 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Wed, 9 Aug 2023 08:56:31 -0400 Subject: [PATCH 2/4] Wrap commit message in a heredoc block to allow single quotes. --- .github/workflows/create-message.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-message.yml b/.github/workflows/create-message.yml index 21a0ac0..d249fd2 100644 --- a/.github/workflows/create-message.yml +++ b/.github/workflows/create-message.yml @@ -31,5 +31,7 @@ jobs: git config --global user.email 'noreply@farmOS.org' - name: Commit/push to farmOS-microblog. run: | - git commit --allow-empty --cleanup=whitespace -m '${{ inputs.message }}' + git commit --allow-empty --cleanup=whitespace -F- << MESSAGE + ${{ inputs.message }} + MESSAGE git push origin main From e0a6b306f20f625d0921e5b32646112d8b22e842 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Wed, 9 Aug 2023 08:23:38 -0400 Subject: [PATCH 3/4] Only publish to Mastodon from the official farmOS repository. --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 149762f..ffb9574 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Mastodon + if: github.repository == 'farmOS/farmOS-microblog' uses: cbrgm/mastodon-github-action@6cffb7d449201bf36a60589de7a76e18ee226043 with: message: ${{ github.event.head_commit.message }} From 788b8c36650a0b8068801385a53172c0c815d702 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Wed, 9 Aug 2023 08:31:06 -0400 Subject: [PATCH 4/4] Echo message for debugging purposes. --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ffb9574..0796811 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,6 +8,8 @@ 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