Skip to content

Update a package

Update a package #44

Workflow file for this run

name: Update a package
on:
workflow_dispatch:
inputs:
package:
type: string
required: true
version:
type: string
default: "latest"
deploy:
type: boolean
default: true
description: Trigger deployment after updating the package.
jobs:
update:
name: Update ${{ inputs.package }}
runs-on: ubuntu-22.04
outputs:
updated: ${{ steps.update-pkg.outputs.updated }}
commit_hash: ${{ steps.git-commit.outputs.commit_hash }}
steps:
- uses: actions/checkout@v3
with:
# Use ref_name instead of ref so we always get the branch to pull our
# latest commit from.
ref: ${{ github.ref_name }}
- name: Install Nix packages
id: nix-install
uses: diamondburned/cache-install@main
with:
shell-file: shell.nix
instantiated-files: packages/
- name: Update package ${{ inputs.package }} to ${{ inputs.version }}
id: update-pkg
run: |-
./scripts/pkg update "${{ inputs.package }}" "${{ inputs.version }}"
# Check if there has been any git changes. updated=1 if there's one,
# otherwise it's 0. We'll skip the rest if 0.
if [[ $(git status --porcelain) ]]; then
echo "updated=1" >> $GITHUB_OUTPUT
fi
env:
# Set the GITHUB_TOKEN variable to prevent 403 errors.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build package ${{ inputs.package }}
if: steps.update-pkg.outputs.updated == 1
run: nix-build ./packages -A "${{ inputs.package }}"
- name: Commit changes, if any
id: git-commit
if: steps.update-pkg.outputs.updated == 1
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: |-
Update package ${{ inputs.package }} using GitHub Actions
Package ${{ inputs.package }} was updated to version:
${{ inputs.version }}
The action workflow was triggered by ref:
${{ github.sha }}
branch: ${{ github.ref_name }}
deploy:
needs: update
if: needs.update.outputs.updated == 1 && inputs.deploy == true
uses: ./.github/workflows/deploy.yml
secrets: inherit