ci: try some thing #88
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: 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: [email protected] | |
# user_name: github-actions | |
# 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.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.PAT }} | |
with: | |
source_file: ${{ matrix.value }} | |
destination_repo: KB-RolePlay/${{ env.REPOSITORY }} | |
destination_folder: lua/${{ env.TARGET_FOLDER }} | |
user_email: [email protected] | |
user_name: github-actions | |
commit_message: Synchronize language from public KB-GModStore repository | |
destination_branch: main |