From c391bf6db4f0fe7abce11bc3a52eadc1168ae8ec Mon Sep 17 00:00:00 2001 From: Diego Albitres Date: Wed, 18 May 2022 00:17:53 -0500 Subject: [PATCH] chore(sync): initial setup of fake API file sync --- .github/sync.yml | 13 +++++++ .github/workflows/json-server.yml | 26 ------------- .github/workflows/sync.yml | 61 +++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 26 deletions(-) create mode 100644 .github/sync.yml delete mode 100644 .github/workflows/json-server.yml create mode 100644 .github/workflows/sync.yml diff --git a/.github/sync.yml b/.github/sync.yml new file mode 100644 index 0000000..9e764d7 --- /dev/null +++ b/.github/sync.yml @@ -0,0 +1,13 @@ +futureleadersupc/waw-backend-json: + - source: server/db.json + dest: db.json + - source: server/routes.json + dest: routes.json + - source: .github/workflows/sync.yml + dest: .github/workflows/sync.yml + +futureleadersupc/waw-frontend-angular: + - source: server/ + dest: server/ + - source: .github/workflows/sync.yml + dest: .github/workflows/sync.yml diff --git a/.github/workflows/json-server.yml b/.github/workflows/json-server.yml deleted file mode 100644 index b7a57ea..0000000 --- a/.github/workflows/json-server.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: json-server - -on: - push: - branches: - - main - paths: - - server/* - -jobs: - publish: - name: 'publish to waw-fake-api repository' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Push directory to another repository - uses: cpina/github-action-push-to-another-repository@v1.4.2 - env: - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} - with: - source-directory: server/ - destination-github-username: 'futureleadersupc' - destination-repository-name: 'waw-fake-api' - user-name: github-actions - user-email: github-actions@github.com - target-branch: main diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000..89e071e --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,61 @@ +name: sync + +on: + push: + branches: + - main + paths: + - server/* + - .github/workflows/sync.yml + +jobs: + file-sync: + name: 'run file sync' + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.sync-output.outputs.pull_request_urls }} + steps: + - name: Checkout current repository + uses: actions/checkout@v3 + - name: Sync files to all repositories + id: sync-output + uses: BetaHuhn/repo-file-sync-action@v1 + with: + GH_PAT: ${{ secrets.BOT_PAT }} + PR_LABELS: | + chore + scope: sync + ASSIGNEES: dalbitresb12-bot + REVIEWERS: ${{ github.actor }} + BRANCH_PREFIX: chore/file-sync + COMMIT_PREFIX: 'chore(sync): ' + COMMIT_EACH_FILE: false + enable-automerge: + name: 'enable auto-merge' + needs: [file-sync] + runs-on: ubuntu-latest + strategy: + matrix: + url: ${{ fromJson(needs.file-sync.outputs.matrix) }} + steps: + - name: Extract pull request info + id: pr-info + env: + CURRENT_URL: ${{ matrix.url }} + shell: python + run: | + import os, re + url = os.environ["CURRENT_URL"] + match = re.fullmatch("^https:\/\/github.com\/(.+)\/(.+)\/pull\/(\d+)$", url) + if (match is None): + print(f"Unable to find a match in {url}") + sys.exit(1) + print(f"::set-output name=repository::{match[1]}/{match[2]}") + print(f"::set-output name=number::{match[3]}") + - name: Enable auto-merge for created pull requests + uses: peter-evans/enable-pull-request-automerge@v2 + with: + token: ${{ secrets.BOT_PAT }} + repository: ${{ steps.pr-info.outputs.repository }} + pull-request-number: ${{ steps.pr-info.outputs.number }} + merge-method: merge