Revision control

Copy as Markdown

name: Update URIs and Create PR
on:
schedule:
- cron: '0 0 1 * *' # Runs at 00:00 on the first day of every month
workflow_dispatch:
inputs:
branchName:
description: 'Branch used as target for automation'
required: true
default: 'main'
jobs:
build:
runs-on: ubuntu-latest # using ubuntu as a lightweight environment
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.inputs.branchName }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# include pyarrow for pandas 3.0 compatibility
pip install pandas pyarrow requests
- name: Run URI update script
run: python test-fixtures/ci/uri_update.py
- name: Check for changes
id: git-check
run: |
if git diff --quiet; then
echo "No changes detected, skipping PR creation."
echo "changes_detected=false" >> $GITHUB_ENV
else
echo "Changes detected, proceeding to create PR."
git diff
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit --allow-empty -m "empty commit" # add empty commit so when squashed the history will show PR title
git add firefox-ios/Shared/Extensions/URLExtensions.swift
echo "changes_detected=true" >> $GITHUB_ENV
datetime=$(date +%Y%m%d%H%M%S)
echo "date=$datetime" >> $GITHUB_ENV
fi
- name: Determine PR Version Number
id: versioning
run: |
# This step is used to determine the next version number for the PR title
# The output includes debugging for the piped commands that generate
# the version number and the last line is the version number itself
output=$(bash test-fixtures/ci/get-next-pr-version)
echo "$output"
next_version=$(echo "$output" | tail -n 1) # get the last line of the output
echo "Next version is: v${next_version}"
echo "next_version=${next_version}" >> $GITHUB_ENV
- name: Create Pull Request
if: env.changes_detected == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Automated URI update on ${{ github.event.inputs.branchName || 'main' }} ${{ env.date }}
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
committer: GitHub <noreply@github.com>
title: Refactor [v${{ env.next_version }}] Automated URI update on ${{ github.event.inputs.branchName || 'main' }} ${{ env.date }}
branch: update-uri-schemes-${{ env.date }}
body: This automated PR updates the URIs.