Automated Releases #378
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automated Releases | |
on: | |
schedule: | |
- cron: 0 0 * * 1,3,5 | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
check-is-fork: | |
# If the workflow is executed in a fork, we don't want to run it | |
# because would fail due to missing permissions and will generate | |
# noise for activity watchers. | |
name: Check if running in a fork | |
runs-on: ubuntu-latest | |
outputs: | |
is-fork: ${{ steps.check.outputs.is-fork }} | |
steps: | |
- name: Set output | |
id: check | |
run: | | |
if [ "${{ github.repository_owner }}" != "simple-icons" ]; then | |
echo "is-fork=true" >> $GITHUB_OUTPUT | |
echo "Auto release only can be executed in the main repository, skipping." | |
else | |
echo "is-fork=false" >> $GITHUB_OUTPUT | |
fi | |
get-releases: | |
name: Check for new release | |
runs-on: ubuntu-22.04 | |
needs: check-is-fork | |
if: needs.check-is-fork.outputs.is-fork == 'false' | |
outputs: | |
si: ${{ steps.releases.outputs.si }} | |
dep: ${{ steps.releases.outputs.dep }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get releases | |
id: releases | |
run: | | |
simple_icons_version="$(curl --retry 15 -s https://api.github.com/repos/simple-icons/simple-icons/releases/latest | jq -r .tag_name)" | |
echo "si=$simple_icons_version" >> $GITHUB_OUTPUT | |
echo "dep=$(grep -i '"simple-icons":' package.json | cut -d'"' -f4)" >> $GITHUB_OUTPUT | |
auto-release: | |
name: Automated release | |
runs-on: ubuntu-latest | |
needs: get-releases | |
if: needs.get-releases.outputs.dep != needs.get-releases.outputs.si | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.BOT_APP_ID }} | |
private-key: ${{ secrets.BOT_PRIVATE_KEY }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
# Ensure we are checked out on the master branch | |
ref: master | |
- name: Setup Rust nightly | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
target: wasm32-unknown-unknown | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
cache: npm | |
- name: Update simple-icons | |
run: | | |
sed -i 's/"simple-icons": "${{needs.get-releases.outputs.dep}}"/"simple-icons": "${{needs.get-releases.outputs.si}}"/' package.json | |
cat package.json | grep '"simple-icons":' -C 2 | |
npm install --package-lock-only --no-audit --no-fund --ignore-scripts | |
- name: Install Node.js dependencies | |
run: npm ci --no-audit --no-fund | |
- name: Install tooling dependencies | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-make,trunk | |
- name: Build | |
run: cargo make build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit updates | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Update simple-icons to ${{ needs.get-releases.outputs.si }} | |
commit_user_name: 'simple-icons[bot]' | |
commit_user_email: 'simple-icons[bot]@users.noreply.github.com' | |
commit_author: 'simple-icons[bot] <simple-icons[bot]@users.noreply.github.com>' |