Atomic Holonix updates #12
This file contains 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: command-listener | |
on: | |
issue_comment: | |
types: ["created"] | |
jobs: | |
action_pr_comment: | |
name: Action PR comment | |
if: ${{ github.event.issue.pull_request }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dispatch | |
id: dispatch | |
env: | |
USER: ${{ github.event.sender.login }} | |
ALLOWED_USERS: ${{ join(fromJson('["ThetaSinner", "jost-s", "maackle", "thedavidmeister", "steveej", "neonphog", "matthme", "c12i"]'), '\n') }} | |
COMMENT: ${{ github.event.comment.body }} | |
run: | | |
set -euo pipefail | |
COMMAND="" | |
if [[ "$COMMENT" == @hra* ]]; then | |
echo "Comment is a command" | |
COMMAND=$(echo "$COMMENT" | cut -b 6- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') | |
else | |
echo "Comment is not a command" | |
exit 0 | |
fi | |
if echo "$ALLOWED_USERS" | grep -q "${USER}"; then | |
echo "User $USER is allowed to run commands" | |
else | |
echo "User $USER is not allowed to run commands" | |
exit 1 | |
fi | |
echo "Setting command '$COMMAND'" | |
echo "action=${COMMAND}" >> "$GITHUB_OUTPUT" | |
outputs: | |
action: ${{ steps.dispatch.outputs.action }} | |
holonix_update: | |
name: Holonix update | |
runs-on: ubuntu-latest | |
needs: [action_pr_comment] | |
if: ${{ startsWith(needs.action_pr_comment.outputs.action, 'holonix_update') }} | |
steps: | |
- name: Configure | |
id: configure | |
env: | |
ACTION: ${{ needs.action_pr_comment.outputs.action }} | |
PR_NUMBER: ${{ github.event.issue.number }} | |
RUN_ID: ${{ github.run_id }} | |
GH_TOKEN: ${{ secrets.HRA_GITHUB_TOKEN }} | |
run: | | |
set -euo pipefail | |
HOLONIX_VERSION=$(echo $ACTION | cut -b 14- | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') | |
gh pr comment $PR_NUMBER --repo holochain/holochain --body "Got it, will try to update inputs for Holonix version \`$HOLONIX_VERSION\` - [Workflow](https://github.com/holochain/holochain/actions/runs/$RUN_ID)" | |
echo "holonix_version=${HOLONIX_VERSION}" >> "$GITHUB_OUTPUT" | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v26 | |
- uses: cachix/cachix-action@v14 | |
with: | |
name: holochain-ci | |
- name: set up git config | |
run: | | |
./scripts/ci-git-config.sh | |
- name: Flake update | |
env: | |
PR_NUMBER: ${{ github.event.issue.number }} | |
HOLONIX_VERSION: ${{ steps.configure.outputs.holonix_version }} | |
GH_TOKEN: ${{ secrets.HRA_GITHUB_TOKEN }} | |
run: | | |
set -euo pipefail | |
gh pr checkout $PR_NUMBER --repo holochain/holochain | |
nix run .#scripts-repo-flake-update $HOLONIX_VERSION | |
git pull --rebase | |
git push |