Revision control

Copy as Markdown

name: Update Outdated Bitrise Steps Versions
on:
#schedule:
# - cron: "0 3 * * 0" # Runs every Sunday at 03:00 UTC
workflow_dispatch: # Allow manual triggering
inputs:
branchName:
description: 'Branch used as target for automation'
required: true
default: 'main'
jobs:
update-steps:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
# Step 2: Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
# Step 4: Run the script to update Bitrise steps
- name: Run update script
id: update_script
run: |
python ./test-fixtures/update_bitrise_steps.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 5: Determine PR Version Number
- 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
echo "current_date=$current_date" >> $GITHUB_ENV
- 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 '.[].name | select(contains("update-bitrise-steps-${{ env.next_version }}"))')
echo $branch
if [ -z "$branch" ]; then echo "BRANCH_CREATED=false" >> $GITHUB_ENV; else echo "BRANCH_CREATED=true" >> $GITHUB_ENV;fi
# Step 6: Check for changes
- name: Commit changes if any
if: env.BRANCH_CREATED == 'false'
run: |
git diff
git diff --quiet || (git add bitrise.yml)
# Step 7: Create a Pull Request
- name: Create a Pull Request
uses: peter-evans/create-pull-request@v6
if: env.BRANCH_CREATED == 'false'
with:
commit-message: "Update [v${{ env.next_version }}] outdated Bitrise steps ${{ env.current_date }}"
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
committer: GitHub <noreply@github.com>
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-bitrise-steps-${{ env.next_version }}
title: "Bump [v${{ env.next_version }}] Update outdated Bitrise steps ${{ env.current_date }}"
delete-branch: true
body: |
This PR updates the outdated Bitrise steps to their latest versions.
reviewers: mdotb-moz,isabelrios,clarmso
# Step 8: Send a message to slack if there is a failure
notify-on-failure:
runs-on: ubuntu-latest
needs: update-steps
if: failure() # Trigger only if the 'update-steps' job fails
steps:
- name: Report to Slack
id: slack
uses: slackapi/slack-github-action@v2.0.0
with:
payload-file-path: "./test-fixtures/ci/slack-notification-payload-update-bitrise-steps.json"
payload-templated: true
webhook: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
webhook-type: incoming-webhook
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUNID: ${{ github.run_id }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_SHA: ${{ github.sha }}