Skip to content

Commit

Permalink
fix: push action (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Sep 21, 2024
1 parent b2ed5e2 commit a903b20
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.7
- uses: ./actions/setup/checkout
- uses: ./actions/setup/variables
- uses: ./actions/setup/node

Expand Down
21 changes: 16 additions & 5 deletions actions/auto/push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,33 @@ runs:
shell: bash
run: |
if [[ "${{ github.base_ref }}" == "" ]]; then
echo "Auto push doesn't support when base_ref is empty"
exit 0;
fi
if [[ "${{ github.event.pull_request.head.repo.full_name != github.repository }}" == "true" ]]; then
echo "Auto push doesn't support from fork"
exit 0;
fi
git config --global user.name "${{ inputs.name }}"
git config --global user.email "${{ inputs.email }}"
git config remote.origin.url https://${{ inputs.name }}:${{ inputs.token }}@github.com/$GITHUB_REPOSITORY
export GITHUB_TOKEN=${{ inputs.token }};
git add .
git remote update
git fetch
git checkout ${{ github.head_ref }}
git status --porcelain
git config --global user.name "${{ inputs.name }}"
git config --global user.email "${{ inputs.email }}"
git remote set-url --push origin https://${{ inputs.name }}:${{ inputs.token }}@github.com/${{ github.repository }}
if [[ `git status --porcelain` ]]; then
git commit --author="${{ inputs.name }} <${{ inputs.name }}@users.noreply.github.com>" \
-m "chore: ${{ inputs.message }} [bot]" \
--no-verify || echo ""
git push origin ${{ github.head_ref }} || echo ""
--no-verify
git push -u origin ${{ github.head_ref }}
else
echo "Nothing to update"
fi
2 changes: 1 addition & 1 deletion actions/messenger/telegram/announce/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ runs:
run: |
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"chat_id\": \"${{ inputs.chatId }}\", \"text\": \"New version [${{ inputs.textLink }}](https://github.com/$GITHUB_REPOSITORY/releases/tag/${{ inputs.version }}) released 🎉\", \"parse_mode\": \"${{ inputs.parseMode }}\", \"message_thread_id\": \"${{ inputs.topicId }}\"}" \
-d "{\"chat_id\": \"${{ inputs.chatId }}\", \"text\": \"New version [${{ inputs.textLink }}](https://github.com/${{ github.repository }}/releases/tag/${{ inputs.version }}) released 🎉\", \"parse_mode\": \"${{ inputs.parseMode }}\", \"message_thread_id\": \"${{ inputs.topicId }}\"}" \
https://api.telegram.org/bot${{ inputs.token }}/sendMessage
2 changes: 1 addition & 1 deletion actions/messenger/time/announce/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ runs:
run: |
curl --http1.1 -X POST \
-H "Content-Type: application/json" \
-d "{\"text\": \"New version [${{ inputs.version }}](https://github.com/$GITHUB_REPOSITORY/releases/tag/${{ inputs.version }}) released :tada:\", \"username\": \"${{ inputs.username }}\", \"channel\": \"${{ inputs.channel }}\"}" \
-d "{\"text\": \"New version [${{ inputs.version }}](https://github.com/${{ github.repository }}/releases/tag/${{ inputs.version }}) released :tada:\", \"username\": \"${{ inputs.username }}\", \"channel\": \"${{ inputs.channel }}\"}" \
${{ inputs.url }}
2 changes: 1 addition & 1 deletion actions/run/rebase/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
- name: Try rebase locally for check affected
uses: imba-tjd/rebase-upstream-action@0.5
with:
upstream: $GITHUB_REPOSITORY
upstream: ${{ github.repository }}
branch: ${{ github.base_ref }}
push: false

Expand Down
2 changes: 1 addition & 1 deletion actions/setup/config/git/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ runs:
run: |
git config user.name "${{ inputs.name }}"
git config user.email "${{ inputs.email }}"
git config remote.origin.url https://x-access-token:${{ inputs.token }}@github.com/$GITHUB_REPOSITORY
git config remote.origin.url https://x-access-token:${{ inputs.token }}@github.com/${{ github.repository }}
git config --global push.followTags true
2 changes: 1 addition & 1 deletion actions/setup/variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ runs:
export NX_CLOUD_DISTRIBUTED_EXECUTION=false
export NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT="8"
export DIST_NEXT="dist/demo/browser/${{ github.base_ref }}"
export REPO="https://github.com/$GITHUB_REPOSITORY"
export REPO="https://github.com/${{ github.repository }}"
export IS_MAIN_BRANCH="${{ github.ref == 'refs/heads/main' }}"
export IS_RELEASE_BRANCH="${{ contains(github.head_ref, 'release/') }}"
export CI_COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
Expand Down

0 comments on commit a903b20

Please sign in to comment.