Skip to content

ci: Fix errors

ci: Fix errors #39

Workflow file for this run

name: Auto PR
on:
push:
branches:
- dev
jobs:
create_or_update_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install GitHub CLI
run: sudo apt-get install gh
- name: Get committer username and email
run: |
committer_username=$(git log -1 --pretty=format:'%an')
committer_email=$(git log -1 --pretty=format:'%ae')
echo "committer_username=$committer_username" >> $GITHUB_ENV
echo "committer_email=$committer_email" >> $GITHUB_ENV
- name: Hash committer username
id: hash_committer
run: |
branch_name=$(echo -n "${{ env.committer_username }}" | md5sum | awk '{ print $1 }')
echo "branch_name=dev_pr_$branch_name" >> $GITHUB_ENV
echo "::set-output name=branch_name::dev_pr_$branch_name"
- name: Configure git
run: |
git config --global user.name "${{ env.committer_username }}"
git config --global user.email "${{ env.committer_email }}"
- name: Create and push new branch based on dev
run: |
git fetch origin
git checkout dev
git pull origin dev
git checkout -b ${{ steps.hash_committer.outputs.branch_name }}
echo "$(date +%s%N)" > timestamp.txt # Create a file with current timestamp in nanoseconds
git add timestamp.txt
git commit -m "Add timestamp file to ensure branch differences"
git pull origin ${{ steps.hash_committer.outputs.branch_name }}
git push origin ${{ steps.hash_committer.outputs.branch_name }}
- name: Create or Update Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.hash_committer.outputs.branch_name }}
base: main
title: "Auto PR from ${{ steps.hash_committer.outputs.branch_name }}"
body: "This is an automated PR created from ${{ steps.hash_committer.outputs.branch_name }}"
draft: false
# update_existing: true # Automatically update the existing PR if it exists
sync_commits:
runs-on: ubuntu-latest
needs: create_or_update_pr
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install GitHub CLI
run: sudo apt-get install gh
- name: Get committer username
run: |
committer_username=$(git log -1 --pretty=format:'%an')
echo "committer_username=$committer_username" >> $GITHUB_ENV
- name: Hash committer username
id: hash_committer
run: |
branch_name=$(echo -n "${{ env.committer_username }}" | md5sum | awk '{ print $1 }')
echo "branch_name=dev_pr_$branch_name" >> $GITHUB_ENV
echo "::set-output name=branch_name::dev_pr_$branch_name"
- name: Fetch and rebase on existing branch
run: |
git fetch origin
git checkout ${{ steps.hash_committer.outputs.branch_name }}
git pull origin ${{ steps.hash_committer.outputs.branch_name }} --rebase || true
if [ -f .git/rebase-apply ]; then
git rebase --abort
git pull --rebase origin ${{ steps.hash_committer.outputs.branch_name }}
fi
git push origin ${{ steps.hash_committer.outputs.branch_name }}