chore: sync workflow to all public repo #482
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: Workflow templates sync | |
on: | |
push: | |
paths: | |
- "repos/**.json" | |
- "workflow-templates/**.yml" | |
- ".github/workflows/templates-sync.yml" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
templates-sync: | |
# limit push on deepin-community/.github master branch | |
if: github.repository == 'deepin-community/.github' && github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
# Install ssh key and known_hosts | |
- name: Git config | |
env: | |
SSH_KEY: ${{secrets.SYNC_SSH_KEY}} | |
KNOWN_HOSTS: ${{secrets.SYNC_SSH_KNOWN_HOSTS}} | |
run: | | |
mkdir ~/.ssh | |
echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts | |
echo "$SSH_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
git config --global user.name deepin-admin-bot | |
git config --global user.email [email protected] | |
git config --global filter.lfs.smudge "git-lfs smudge --skip -- %f" | |
git config --global filter.lfs.process "git-lfs filter-process --skip" | |
# Clone Repository | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# Incremental sync when config changed | |
- name: Check changed configs | |
id: changed-configs | |
uses: tj-actions/[email protected] | |
with: | |
separator: " " | |
files: repos/deepin-community/*.json | |
write_output_files: true | |
- name: Get changed configs | |
if: steps.changed-configs.outputs.any_changed == 'true' | |
run: | | |
mv .github/outputs/all_changed_files.txt /tmp/template_sync_config.list | |
# Full sync when file changed or workflow_dispatch event | |
- name: Check changed workflow | |
id: changed-workflow | |
uses: tj-actions/[email protected] | |
with: | |
separator: " " | |
files: | | |
workflow-templates/**.yml | |
.github/workflows/templates-sync.yml | |
- name: Get all configs | |
id: all-configs | |
if: steps.changed-workflow.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' | |
run: | | |
find repos -type f | grep json | xargs > /tmp/template_sync_config.list | |
# Run sync action | |
- name: Sync files | |
uses: linuxdeepin/action-sync@main | |
with: | |
files-from: /tmp/template_sync_config.list | |
message: "chore: Sync by ${{ github.event.head_commit.url }}" |