Fetch new commits from remote repos #2
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: Fetch new commits from remote repos | |
on: | |
workflow_dispatch: | |
# schedule: | |
# - cron: '0 4 * * *' # Runs every day at 4 AM UTC | |
jobs: | |
run-swift-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Load secrets from 1Password | |
id: onepw_secrets | |
uses: 1password/[email protected] | |
with: | |
export-env: true # Export loaded secrets as environment variables | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
GITHUB_TOKEN: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/GitHub generic action token for all repos/credential" | |
- name: Run Swift Script | |
id: run-swift-script | |
run: | | |
OUTPUT=$(swift scripts/monitor-remote-repos-for-new-commits.swift) | |
echo "swift_output=$OUTPUT" >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} | |
- name: Parse Output | |
id: parse-output | |
run: | | |
FOUND_COMMITS=$(echo "$swift_output" | jq -r '.found_commits') | |
BRANCH_NAME=$(echo "$swift_output" | jq -r '.branch_name') | |
ISSUE_TITLE=$(echo "$swift_output" | jq -r '.issue_title') | |
ISSUE_BODY=$(echo "$swift_output" | jq -r '.issue_body' | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/|/\\|/g') | |
echo "found_commits=$FOUND_COMMITS" >> $GITHUB_OUTPUT | |
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
echo "issue_title=$ISSUE_TITLE" >> $GITHUB_OUTPUT | |
echo "issue_body=$ISSUE_BODY" >> $GITHUB_OUTPUT | |
- name: Create issue | |
id: create-issue | |
# if: steps.parse-output.outputs.found_commits == 'true' | |
uses: dacbd/[email protected] | |
with: | |
token: ${{ env.GITHUB_TOKEN }} | |
assignees: Sergiodero | |
title: ${{ steps.parse-output.outputs.issue_title }} | |
body: ${{ steps.parse-output.outputs.issue_body }} |