From dca38a39c865555e9ce6f68f7dc8b08eeeb12c4b Mon Sep 17 00:00:00 2001 From: Umair Jibran Date: Sat, 20 May 2023 13:31:13 +0500 Subject: [PATCH] CONFIG: create repo at action --- action.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index f2a4b62..2dfd18b 100644 --- a/action.yml +++ b/action.yml @@ -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 }}