Skip to content

Commit

Permalink
CONFIG: create repo at action
Browse files Browse the repository at this point in the history
  • Loading branch information
UmairJibran committed May 20, 2023
1 parent a7734e7 commit dca38a3
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,35 @@ runs:
using: 'composite'
steps:
- run: |
echo https://${{ github.repository_owner }}:${{ env.GITHUB_PAT }}@github.com/${{ github.repository }}.git
echo "SETTING UP GIT CONFIG"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
pwd
ls -lah
git remote set-url origin https://${{ github.repository_owner }}:${{ env.GITHUB_PAT }}@github.com/${{ github.repository }}.git
git fetch
echo "INITIALIZING GIT REPO"
git init
echo "SETTING UP GIT REMOTE"
git remote add origin https://${{ github.repository_owner }}:${{ env.GITHUB_PAT }}@github.com/${{ github.repository }}.git
echo "GETTING DEFAULT BRANCH"
BRANCH=${{ github.event.repository.default_branch }}
echo "FETCHING LATEST CODE AT $BRANCH"
git fetch origin $BRANCH
echo "CHECKING OUT $BRANCH"
git checkout $BRANCH
git pull
if ! git rev-parse --verify ${{ env.TARGET_BRANCH }} >/dev/null 2>&1; then
git checkout ${{ github.event.repository.default_branch }}
git pull
echo "CREATING ${{ env.TARGET_BRANCH }}"
git branch ${{ env.TARGET_BRANCH }}
echo "PUSHING ${{ env.TARGET_BRANCH }}"
git push --set-upstream origin ${{ env.TARGET_BRANCH }}
fi
echo "CHECKING OUT ${{ env.TARGET_BRANCH }}"
git checkout ${{ env.TARGET_BRANCH }}
echo "PULLING CHANGES IF ANY"
git pull
echo "MERGING PR IN ${{ env.TARGET_BRANCH }}"
git merge --no-ff origin/${{ github.event.pull_request.head.ref }} -m "Merge pull request into ${{ env.TARGET_BRANCH }}"
echo "PUSHING CHANGES TO ${{ env.TARGET_BRANCH }}"
git push origin ${{ env.TARGET_BRANCH }}
shell: bash
env:
TARGET_BRANCH: ${{ inputs.target-branch }} # INPUTS_TARGET-BRANCH
GITHUB_PAT: ${{ inputs.token }} # INPUTS_TOKEN
TARGET_BRANCH: ${{ inputs.target-branch }}
GITHUB_PAT: ${{ inputs.token }}

0 comments on commit dca38a3

Please sign in to comment.