Skip to content

chore: cleanup unneeded CI #3

chore: cleanup unneeded CI

chore: cleanup unneeded CI #3

name: Update and Validate Upstream Scripts
on:
push:
branches-ignore:
- feat/update-*
workflow_dispatch:
inputs:
dry_run:
description: "Run without creating a pull request"
required: false
default: "true"
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
update-and-validate:
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout Repository at workflow sha
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
ssh-key: ${{ secrets.AUTOMATED_PRANAVMISHRA90_SSHKEY }}
- name: Setup | Force correct release branch on workflow SHA
run: |
git checkout -B ${{ github.ref_name }}
- name: Setup | Configure Git
run: |
git config --global user.email "62562712+pranavmishra90@users.noreply.github.com"
git config --global user.name "Pranav Kumar Mishra"
if ! ssh-add -l | grep -q "ED25519"; then
echo "No SSH key found in agent. Trying to restart the ssh-agent."
eval "$(ssh-agent -s)"
ssh-add - <<< "${{ secrets.AUTOMATED_PRANAVMISHRA90_SSHKEY }}"
fi
if ! ssh-add -l | grep -q "ED25519"; then
echo "No SSH key found in agent. Disabling commit signing."
git config --global commit.gpgsign false
else
echo "SSH key found in agent. Enabling commit signing."
git config --global user.signingkey "ssh-ed25519 ${{ secrets.AUTOMATED_PRANAVMISHRA90_SSH_PUBKEY }} Automated_Signature-Pranav_Mishra"
git config --global gpg.format ssh
git config --global commit.gpgsign true
fi
- name: Modify script URLs and fix permissions
shell: bash
run: ./.github/workflows/scripts/pranavmishra90/mod-upstream-scripts.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SSH_KEY: ${{ secrets.AUTOMATED_PRANAVMISHRA90_SSHKEY }}
- name: Add a date stamp
id: date_stamp
run: |
DATESTAMP=$(date +%Y-%m-%d)
echo "timestamp=$DATESTAMP" >> $GITHUB_ENV
echo "Generated timestamp: $DATESTAMP"
create-pr:
name: Create Pull Request
needs: update-and-validate
runs-on: ubuntu-latest
steps:
- name: Get the branch name
id: get_branch_name
run: |
DATE=$(date +%Y-%m-%d)
BRANCH_NAME="feat/update-$DATE"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Setup | Checkout Repository at workflow sha
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.BRANCH_NAME }}
- name: Setup | Force correct release branch on workflow SHA
run: |
echo "Trying to pull any changes: ${BRANCH_NAME}"
git push -v -u origin ${BRANCH_NAME}
git pull -v origin ${BRANCH_NAME}
- name: Add a date stamp
id: date_stamp
run: |
DATESTAMP=$(date +%Y-%m-%d)
echo "timestamp=$DATESTAMP" >> $GITHUB_ENV
echo "Generated timestamp: $DATESTAMP"
- name: Dry Run Check
id: dry_run_check
run: |
echo "DRY_RUN=${{ github.event.inputs.dry_run }}" >> $GITHUB_ENV
echo "Dry run mode is set to: ${{ github.event.inputs.dry_run }}"
- name: Unset git configuration
if: env.DRY_RUN == 'true'
run: |
echo "Disabling commit signing for dry run mode."
git config --global --unset user.signingkey
git config --global --unset gpg.format
git config --global --unset commit.gpgsign
git config --global --unset tag.gpgSign
- name: Create Pull Request
id: create_pr
if: env.DRY_RUN != 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
git config --global user.email "62562712+pranavmishra90@users.noreply.github.com"
git config --global user.name "Pranav Kumar Mishra"
git checkout --no-track -B ci/automated-update ${{ env.BRANCH_NAME }}
git branch --set-upstream-to=origin/ci/automated-update ci/automated-update
if gh pr list --base main --head ci/automated-update --json number --jq '. | length > 0'; then
echo "Pull request already exists between main and ci/automated-update."
git pull -v origin ci/automated-update --no-rebase
git push -u -v origin ci/automated-update
echo "Updated the existing pull request with the latest changes."
else
echo "No pull request exists. Proceeding to create a new pull request."
git pull -v origin ci/automated-update --no-rebase
git push -u -v origin ci/automated-update
gh pr create --base main \
--head ci/automated-update \
--title "Updated scripts from upstream [${{ env.timestamp }}]" \
--body "This PR updates the scripts from the upstream repository.<br><br> - URLs have been modified to this fork. <br> - Permissions have been fixed."
fi