Skip to content

Commit

Permalink
Do repo-sync & refs update in one single job
Browse files Browse the repository at this point in the history
  • Loading branch information
orviz committed Dec 11, 2023
1 parent e539b76 commit 5c88a8c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 52 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/references.yml

This file was deleted.

37 changes: 29 additions & 8 deletions .github/workflows/repo-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,40 @@ jobs:
name: Repo Sync
runs-on: ubuntu-latest
steps:
- name: Extract local & upstream repository name (eosc-synergy)
if: contains(github.repository, 'eosc-synergy')
run: |
echo "REPO_NAME_LOCAL=https://github.com/eosc-synergy/FAIR_eva" >> "$GITHUB_ENV"
echo "REPO_NAME_UPSTREAM=https://github.com/IFCA-Advanced-Computing/FAIR_eva" >> "$GITHUB_ENV"
- name: Extract local & upstream repository name (IFCA-Advanced-Computing)
if: contains(github.repository, 'IFCA-Advanced-Computing')
run: |
echo "REPO_NAME_LOCAL=https://github.com/eosc-synergy/FAIR_eva" >> "$GITHUB_ENV"
echo "REPO_NAME_UPSTREAM=https://github.com/IFCA-Advanced-Computing/FAIR_eva" >> "$GITHUB_ENV"
- name: Print local & upstream repository variables
run: |
echo "Using local repository: $REPO_NAME_LOCAL"
echo "Using upstream repository: $REPO_NAME_UPSTREAM"
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: repo-sync/github-sync@v2
name: Sync repo to branch
name: Sync repo to branch <repo-sync>
with:
source_repo: https://github.com/IFCA-Advanced-Computing/FAIR_eva
source_repo: $REPO_NAME_UPSTREAM
source_branch: main
destination_branch: repo-sync
github_token: ${{ secrets.GITHUB_TOKEN }}
# - uses: repo-sync/pull-request@v2
# name: Create pull request
# with:
# source_branch: repo-sync
# destination_branch: merge/repo-sync
# github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: peter-evans/create-pull-request@v5
name: Create pull request
with:
base: repo-sync
branch: repo-sync/merge-refs
title: Synchronize repository with upstream contents
- run: bash -x ./.github/workflows/scripts/set_refs.sh $REPO_NAME_LOCAL
- run: git status
- uses: peter-evans/create-pull-request@v5
name: Create/update pull request
with:
base: repo-sync/merge-refs
title: Update references on repo-sync/merge-refs branch
27 changes: 14 additions & 13 deletions .github/workflows/scripts/set_refs.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/bin/bash

BRANCH_NAME=$1
ORG_LOCAL=eosc-synergy
ORG_UPSTREAM=IFCA-Advanced-Computing
REPO_NAME_LOCAL=$1
SYNERGY_PATTERN=eosc-synergy
IFCA_PATTERN=ifca-advanced-computing

[[ -z $BRANCH_NAME ]] && echo "Ignoring: no branch name provided" && exit -1
[[ $# -ne 1 ]] && echo "Ignoring: bad arguments provided" && exit -1

if [[ $BRANCH_NAME == "merge/repo-sync" ]]; then
echo "Setting references to eosc-synergy"
find . -type f \( -name \*.md -o -name \*.rst -o -name \*.toml -o -name \*.html -o -name \*.cff \) -exec sed -i "s/${ORG_UPSTREAM}\/FAIR_eva/${ORG_LOCAL}\/FAIR_eva/gI" {} +
elif [[ $BRANCH_NAME == "merge/upstream" ]]; then
echo "Setting references to IFCA-Advanced-Computing"
find . -type f \( -name \*.md -o -name \*.rst -o -name \*.toml -o -name \*.html -o -name \*.cff -o -name Dockerfile \) -exec sed -i "s/${ORG_LOCAL}\/FAIR_eva/${ORG_UPSTREAM}\/FAIR_eva/gI" {} +
else
echo "Ignoring: branch name <$BRANCH_NAME> is not in [merge/repo-sync, merge/upstream]"
fi
case ${REPO_NAME_LOCAL,,} in
*eosc-synergy*)
find . -type f \( -name \*.md -o -name \*.rst -o -name \*.toml -o -name \*.html -o -name \*.cff -o -name Dockerfile \) -exec sed -i "s/${IFCA_PATTERN}\/FAIR_eva/${SYNERGY_PATTERN}\/FAIR_eva/gI" {} +
;;
*ifca-advanced-computing*)
find . -type f \( -name \*.md -o -name \*.rst -o -name \*.toml -o -name \*.html -o -name \*.cff -o -name Dockerfile \) -exec sed -i "s/${SYNERGY_PATTERN}\/FAIR_eva/${IFCA_PATTERN}\/FAIR_eva/gI" {} +
;;
*) echo "No pattern matching found"
;;
esac

0 comments on commit 5c88a8c

Please sign in to comment.