Skip to content

form-submission

form-submission #117

# Github action triggered as webhook from a netlify function
# NB!!!! this MUST be on the branch set as GitHub's default if it is to be triggered
name: Process Form Submission
on:
repository_dispatch:
types: [form-submission]
jobs:
process-submission:
name: Process Form
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add new file to workspace
run: "jq '.client_payload.form' $GITHUB_EVENT_PATH > _data/$REPOSITORY/submissions/$SUBMISSION_REF.json"
env:
SUBMISSION_REF: ${{ github.event.client_payload.form.submission_ref }}
REPOSITORY: ${{ github.event.client_payload.form.repository }}
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: Add form submission
committer: GitHub <[email protected]>
author: Form process <[email protected]>
signoff: false
branch: form-submission/${{ github.event.client_payload.form.submission_ref }}
branch-suffix: random # handle concurrent submissions of same form id
delete-branch: true
title: "New form submission '${{ github.event.client_payload.form.form_name }}' - ${{ github.event.client_payload.form.submission_ref }}"
body: |
New form submission:
- form_name: ${{ github.event.client_payload.form.form_name }}
- form_version: ${{ github.event.client_payload.form.form_version }}
- submission_ref: ${{ github.event.client_payload.form.submission_ref }}
- submission_date: ${{ github.event.client_payload.form.submission_date }}
View the submitted JSON in the "Files changed" tab above.
Merge this PR to add the submission to `_data/${{ github.event.client_payload.form.repository }}/submissions`.
labels: |
form submission
automated pr
draft: false