Revision control

Copy as Markdown

name: Create a PR to update Kingfisher to the newest version available
on:
schedule:
- cron: '0 8 * * 1'
workflow_dispatch:
inputs:
branchName:
description: 'Branch used as target for automation'
required: true
default: 'main'
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./test-fixtures/requirements.txt
- name: Update Kingfisher version in Package.swift and all Package.resolved files
run: |
python ./test-fixtures/update-kingfisher-version.py
- name: Get new Kingfisher version to be used in the PR info
run: |
if [ -f test-fixtures/newest_kingfisher_tag.txt ]; then
echo "kingfisher_version=$(cat test-fixtures/newest_kingfisher_tag.txt | tr -d '[:space:]')" >> $GITHUB_ENV
fi
- name: Remove temp file created to store the tag info
run: |
[ ! -e test-fixtures/newest_kingfisher_tag.txt ] || rm test-fixtures/newest_kingfisher_tag.txt
- name: Script to check if branch exists to not commit again
run: |-
branch=$(curl -X GET -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/mozilla-mobile/firefox-ios/branches?per_page=100 | jq -r --arg tag "update-spm-new-kingfisher-tag-${kingfisher_version}" '.[].name | select(contains($tag))')
echo $branch
if [ -z "$branch" ]; then echo "BRANCH_CREATED=false" >> $GITHUB_ENV; else echo "BRANCH_CREATED=true" >> $GITHUB_ENV; fi
- name: Determine PR Version Number
id: versioning
run: |
output=$(bash test-fixtures/ci/get-next-pr-version)
echo "$output"
next_version=$(echo "$output" | tail -n 1)
echo "Next Firefox iOS version is: v${next_version}"
echo "next_app_version=${next_version}" >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6
if: env.BRANCH_CREATED == 'false' && env.kingfisher_version != ''
with:
commit-message: Auto update SPM with latest Kingfisher release ${{ env.kingfisher_version }}
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
committer: GitHub <noreply@github.com>
title: Bump FXIOS [Dependency] Auto update SPM for v${{ env.next_app_version }} with latest Kingfisher ${{ env.kingfisher_version }}
branch: update-spm-new-kingfisher-tag-${{ env.kingfisher_version }}
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: |
BrowserKit/Package.swift
BrowserKit/Package.resolved
firefox-ios/Client.xcodeproj/project.pbxproj
firefox-ios/Client.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
SampleComponentLibraryApp/SampleComponentLibraryApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
focus-ios/Blockzilla.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
- name: Set job log URL
if: always()
- name: Send Slack notification if action fails
if: '!cancelled()'
id: slack
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
env:
ACTION_NAME: Kingfisher dependency update
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
with:
payload-file-path: "./test-fixtures/ci/slack-notification-payload-generic.json"
payload-templated: true
webhook: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
webhook-type: incoming-webhook