Skip to content

Merge pull request #93 from pyrmamarius/patch-2 #96

Merge pull request #93 from pyrmamarius/patch-2

Merge pull request #93 from pyrmamarius/patch-2 #96

name: Push languages files to private repositories
on:
push:
branches:
- main
jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
-
name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
-
name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v41
with:
files_ignore: .github/**
json: true
-
name: Set matrix value
id: set-matrix
run: echo "::set-output name=matrix::${{ steps.changed-files.outputs.all_changed_files }}}"
push:
needs: [ setup ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
value: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
-
name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
-
name: Extract folder name of the path
id: folder-name
run: |
echo "REPOSITORY=$(echo "${{ matrix.value }}" | cut -d'/' -f 1)" >> $GITHUB_ENV
echo "TARGET_FOLDER=$(echo "${{ matrix.value }}" | cut -d'/' -f 2- | rev | cut -d '/' -f 2- | rev)" >> $GITHUB_ENV
-
name: Push file
uses: dmnemec/[email protected]
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
source_file: ${{ matrix.value }}
destination_repo: ${{ github.REPOSITORY_OWNER }}/${{ env.REPOSITORY }}
destination_folder: lua/${{ env.TARGET_FOLDER }}
user_email: 41898282+github-actions[bot]@users.noreply.github.com
user_name: github-actions[bot]
commit_message: Synchronize language from public repository
destination_branch: develop
kbrpPush:
needs: [ setup ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
value: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
-
name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
-
name: Extract folder name of the path
id: folder-name
run: |
echo "REPOSITORY=$(echo "${{ matrix.value }}" | cut -d'/' -f 1)" >> $GITHUB_ENV
echo "TARGET_FOLDER=$(echo "${{ matrix.value }}" | cut -d'/' -f 2- | rev | cut -d '/' -f 2- | rev)" >> $GITHUB_ENV
-
name: Check if the env.REPOSITORY exists in the KB-RolePlay organization
id: check-repo
run: |
status_code=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.KBRP_PAT }}" https://api.github.com/repos/KB-RolePlay/${{ env.REPOSITORY }})
echo "REPOSITORY_EXISTS=$status_code" >> $GITHUB_ENV
-
name: Push file
uses: dmnemec/[email protected]
if: ${{ env.REPOSITORY_EXISTS < 400 }}
env:
API_TOKEN_GITHUB: ${{ secrets.KBRP_PAT }}
with:
source_file: ${{ matrix.value }}
destination_repo: KB-RolePlay/${{ env.REPOSITORY }}
destination_folder: lua/${{ env.TARGET_FOLDER }}
user_email: 41898282+github-actions[bot]@users.noreply.github.com
user_name: github-actions[bot]
commit_message: "ci(langs): Synchronize language from public KB-GModStore repository"
destination_branch: main