Skip to content

Synchronize upstream #70

Synchronize upstream

Synchronize upstream #70

Workflow file for this run

name: Synchronize upstream
on:
workflow_dispatch:
inputs:
project:
type: choice
description: upstream project name
options:
- dae
- daed
required: true
suffix:
type: string
required: false
default: "unstable"
description: suffix of package name, e.g. unstable, release
revision:
type: string
required: false
description: revision to sync
jobs:
sync-upstream:
runs-on: ubuntu-latest
steps:
- name: Generate GitHub auth token
# https://github.com/tibdex/github-app-token
id: generate_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: actions/checkout@main
with:
token: ${{ steps.generate_token.outputs.token }}
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: Update unstable package
id: "update-unstable"
if: "${{ github.event.inputs.revision == '' && github.event.inputs.suffix == 'unstable' }}"
run: |
nix develop -c ./main.nu sync ${{ inputs.project }} unstable
- name: Update package with revision
id: "update-with-rev"
# skip while revision set but suffix keeps default (unstable)
if: "${{ steps.update-unstable.outcome == 'skipped' && github.event.inputs.suffix != 'unstable' }}"
run: |
nix develop -c ./main.nu sync ${{ inputs.project }} ${{ inputs.suffix }} --rev ${{ inputs.revision }}
- name: Check package update step outcome
run: |
if [[ "${{ steps.update-with-rev.outcome }}" != "success" && "${{ steps.update-unstable.outcome }}" != "success" ]]; then
echo "Update Package Failed"
exit 1
fi
- name: Commit changes
uses: EndBug/add-and-commit@main
with:
add: "metadata.json"
commit: --signoff
message: "chore(${{ inputs.project }}): sync to refs/head/main"
push: false
- name: Push to sync-target
run: |
git checkout -b sync-target
git push -u origin sync-target
- name: Build
run: |
#!/usr/bin/env bash
set -exuo pipefail
nix build .#${{ inputs.project }}-${{ inputs.suffix }}
- name: Create Pull Request
uses: actions/github-script@main
with:
github-token: ${{ steps.generate_token.outputs.token }}
script: |
const { PROJECT, SUFFIX, REVISION } = process.env
const { data: pull_request } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `chore(${PROJECT}): sync to ${REVISION || "refs/head/main"}`,
body: `This PR merges the ${PROJECT}-${SUFFIX} latest update from upstream.`,
head: 'sync-target',
base: 'main',
});
console.log(`Created pull request ${pull_request.number}`);
env:
PROJECT: ${{ inputs.project }}
SUFFIX: ${{ inputs.suffix }}
REVISION: ${{ inputs.revision }}