134 lines
4.6 KiB
YAML
134 lines
4.6 KiB
YAML
---
|
|
# This workflow is centrally managed in https://github.com/<organization>/.github/
|
|
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
|
|
# the above-mentioned repo.
|
|
|
|
# To use, add the `pacman-pkg` repository label to identify repositories that should trigger this workflow.
|
|
|
|
# Update pacman repo on release events.
|
|
|
|
name: Update pacman repo
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
release:
|
|
types:
|
|
- released
|
|
|
|
concurrency:
|
|
group: "${{ github.workflow }}-${{ github.event.release.tag_name }}"
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
update-homebrew-release:
|
|
if: github.repository_owner == 'LizardByte'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check if pacman repo
|
|
id: check-label
|
|
env:
|
|
TOPIC: pacman-pkg
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const topic = process.env.TOPIC;
|
|
console.log(`Checking if repo has topic: ${topic}`);
|
|
|
|
const repoTopics = await github.rest.repos.getAllTopics({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo
|
|
});
|
|
console.log(`Repo topics: ${repoTopics.data.names}`);
|
|
|
|
const hasTopic = repoTopics.data.names.includes(topic);
|
|
console.log(`Has topic: ${hasTopic}`);
|
|
|
|
core.setOutput('hasTopic', hasTopic);
|
|
|
|
- name: Check if latest GitHub release
|
|
id: check-release
|
|
if: >-
|
|
steps.check-label.outputs.hasTopic == 'true'
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const latestRelease = await github.rest.repos.getLatestRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo
|
|
});
|
|
|
|
core.setOutput('isLatestRelease', latestRelease.data.tag_name === context.payload.release.tag_name);
|
|
|
|
- name: Checkout pacman-repo
|
|
if: >-
|
|
steps.check-label.outputs.hasTopic == 'true' &&
|
|
steps.check-release.outputs.isLatestRelease == 'true'
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ github.repository_owner }}/pacman-repo
|
|
|
|
- name: Prep
|
|
id: prep
|
|
if: >-
|
|
steps.check-label.outputs.hasTopic == 'true' &&
|
|
steps.check-release.outputs.isLatestRelease == 'true'
|
|
run: |
|
|
echo "pkg_name=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download release asset
|
|
id: download
|
|
if: >-
|
|
steps.check-label.outputs.hasTopic == 'true' &&
|
|
steps.check-release.outputs.isLatestRelease == 'true'
|
|
uses: robinraju/release-downloader@v1.12
|
|
with:
|
|
repository: "${{ github.repository }}"
|
|
tag: "${{ github.event.release.tag_name }}"
|
|
fileName: "*.pkg.tar.gz"
|
|
tarBall: false
|
|
zipBall: false
|
|
out-file-path: "pkgbuilds/${{ steps.prep.outputs.pkg_name }}"
|
|
extract: true
|
|
|
|
- name: Remove pkg.tar.gz
|
|
if: >-
|
|
steps.check-label.outputs.hasTopic == 'true' &&
|
|
steps.check-release.outputs.isLatestRelease == 'true' &&
|
|
fromJson(steps.download.outputs.downloaded_files)[0]
|
|
run: |
|
|
rm -f "pkgbuilds/${{ steps.prep.outputs.pkg_name }}"
|
|
|
|
- name: Create/Update Pull Request
|
|
id: create-pr
|
|
if: >-
|
|
steps.check-label.outputs.hasTopic == 'true' &&
|
|
steps.check-release.outputs.isLatestRelease == 'true' &&
|
|
fromJson(steps.download.outputs.downloaded_files)[0]
|
|
uses: peter-evans/create-pull-request@v7
|
|
with:
|
|
add-paths: |
|
|
pkgbuilds/*
|
|
token: ${{ secrets.GH_BOT_TOKEN }}
|
|
commit-message: "chore: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}"
|
|
branch: bot/bump-${{ github.repository }}-${{ github.event.release.tag_name }}
|
|
delete-branch: true
|
|
title: "chore: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}"
|
|
body: ${{ github.event.release.body }}
|
|
labels: |
|
|
auto-approve
|
|
auto-merge
|
|
|
|
- name: Automerge PR
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
|
|
if: >-
|
|
steps.check-label.outputs.hasTopic == 'true' &&
|
|
steps.check-release.outputs.isLatestRelease == 'true' &&
|
|
fromJson(steps.download.outputs.downloaded_files)[0]
|
|
run: |
|
|
gh pr merge \
|
|
--auto \
|
|
--delete-branch \
|
|
--squash \
|
|
"${{ steps.create-pr.outputs.pull-request-number }}"
|