From afcb0b1ea76a73f10ff62f5debea440707e98c87 Mon Sep 17 00:00:00 2001 From: Pavel Popov Date: Tue, 22 Feb 2022 00:35:48 +0300 Subject: [PATCH] Add sync action (#2) * Add workflow sync * Add sync action --- .github/workflows/basic-linters.yml | 5 ++ .github/workflows/sync.yml | 68 ++++++++++++++++++++++++++++ LICENSE | 1 - workflow-templates/auto-tag.yml | 3 +- workflow-templates/basic-linters.yml | 7 ++- 5 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/basic-linters.yml b/.github/workflows/basic-linters.yml index 00652f7..60b10c5 100644 --- a/.github/workflows/basic-linters.yml +++ b/.github/workflows/basic-linters.yml @@ -4,6 +4,11 @@ on: pull_request: branches: - master + - main + push: + branches: + - master + - main jobs: lint: diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000..ae305ca --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,68 @@ +name: Vality workflows sync + +on: + push: + branches: + - master + - main + +env: + REPO_LIMIT: 1000 + +jobs: + workflows-sync: + name: Sync files in ${{ matrix.language }} repositories + runs-on: ubuntu-latest + strategy: + matrix: + include: + - language: thrift + file_patterns: | + ^LICENSE$ + workflow_patterns: | + ^basic-linters\.yml$ + - language: erlang + file_patterns: | + ^LICENSE$ + workflow_patterns: | + ^basic-linters\.yml$ + - language: java + file_patterns: | + ^LICENSE$ + workflow_patterns: | + ^basic-linters\.yml$ + steps: + - name: 📤 Get a list of ${{ matrix.language }} repositories + run: | + REPOSITORIES=$(gh repo list \ + $OWNER \ + --source \ + --no-archived \ + -L $REPO_LIMIT \ + - l ${{ matrix.language }} \ + --json name,owner \ + -q '.[] | [.owner.login, .name] | join("/")') + echo "REPOSITORIES<> $GITHUB_ENV + echo "$REPOSITORIES" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + - name: 🔄 Sync main files + uses: adrianjost/files-sync-action@v1.5.0 + with: + TARGET_REPOS: ${{ env.REPOSITORIES }} + FILE_PATTERNS: ${{ matrix.file_patterns }} + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + GIT_EMAIL: ${{ secrets.GIT_EMAIL }} + GIT_USERNAME: ${{ secrets.GIT_USERNAME }} + - name: 🔄 Sync workflow files + uses: adrianjost/files-sync-action@v1.5.0 + with: + TARGET_REPOS: ${{ env.REPOSITORIES }} + FILE_PATTERNS: ${{ matrix.workflow_patterns }} + SRC_ROOT: "/workflow-templates/" + TARGET_ROOT: "/.github/workflows/" + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + GIT_EMAIL: ${{ secrets.GIT_EMAIL }} + GIT_USERNAME: ${{ secrets.GIT_USERNAME }} diff --git a/LICENSE b/LICENSE index f13a843..d9a10c0 100644 --- a/LICENSE +++ b/LICENSE @@ -174,4 +174,3 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - \ No newline at end of file diff --git a/workflow-templates/auto-tag.yml b/workflow-templates/auto-tag.yml index 49bc889..eb4bf49 100644 --- a/workflow-templates/auto-tag.yml +++ b/workflow-templates/auto-tag.yml @@ -3,7 +3,8 @@ name: Vality auto-tags on: push: branches: - - $default-branch + - master + - main jobs: lint: diff --git a/workflow-templates/basic-linters.yml b/workflow-templates/basic-linters.yml index 970b59d..60b10c5 100644 --- a/workflow-templates/basic-linters.yml +++ b/workflow-templates/basic-linters.yml @@ -3,7 +3,12 @@ name: Vality basic linters on: pull_request: branches: - - $default-branch + - master + - main + push: + branches: + - master + - main jobs: lint: