Skip to content

Commit

Permalink
Use a self hosted runner to executre the job
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Nov 11, 2024
1 parent db5edb7 commit f6e425c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
48 changes: 45 additions & 3 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
check:
env:
SHARED_SECRET: abc123
runs-on: ubuntu-latest
runs-on: self-hosted
permissions:
contents: read
id-token: write
Expand Down Expand Up @@ -52,8 +52,50 @@ jobs:
- name: download sheet
run: |-
./scripts/download.sh "${{ github.event.inputs.url }}" "${{ github.event.inputs.range }}" "${{ steps.auth.outputs.access_token }}"
curl -v \
STATUS=$(curl -v \
-w '%{http_code}' \
-H "X-Secret: $SHARED_SECRET" \
-XPOST \
--upload-file csv.json \
http://localhost:8080/workbench/check
http://localhost:8080/workbench/check)
if [ ${STATUS} -gt 299 ]; then
echo "Check my work failed"
exit 1
fi
env:
URL: ${{ github.event.inputs.url }}
RANGE: ${{ github.event.inputs.range }}
ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}

- name: run
run: ./fabricator --source source.csv --target target.csv

- name: Checkout workbench
uses: actions/checkout@v4
with:
repository: lehigh-university-libraries/islandora_workbench
ref: simple-field-json
path: islandora_workbench

- name: execute
working-dir: islandora_workbench
env:
ISLANDORA_WORKBENCH_PASSWORD: ${{ secrets.ISLANDORA_WORKBENCH_PASSWORD }}
run: |-
mkdir logs
wc -l source.csv
exit 1
if [ -f source.agents.csv ]; then
python3 workbench --config configs/terms.yml
fi
python3 workbench --config configs/create.yml
- name: Notify Slack after job runs
if: always()
run: |-
exit 0
curl -s -o /dev/null -XPOST $SLACK_WEBHOOK_URL -d '{
"text": ":islandora: :hammer_and_wrench: Workbench job complete ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#step:8:1",
}'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
9 changes: 6 additions & 3 deletions scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
set -eou pipefail

# extract sheet ID from https://docs.google.com/spreadsheets/d/foo/edit?gid=0#gid=0
SHEET_ID=$(echo "$1" | sed -n 's|.*/d/\(.*\)/.*|\1|p')
RANGE=$2
ACCESS_TOKEN=$3
SHEET_ID=$(echo "$URL" | sed -n 's|.*/d/\(.*\)/.*|\1|p')

# Fetch data from the Google Sheet
response=$(curl -s \
"https://sheets.googleapis.com/v4/spreadsheets/$SHEET_ID/values/$RANGE" \
-H "Authorization: Bearer $ACCESS_TOKEN")

# download JSON format check my work expects
json_data=$(echo "$response" | jq -r '.values | map(map(tostring))')
echo "$json_data" > csv.json

# download CSV format
csv_url="https://docs.google.com/spreadsheets/d/$SHEET_ID/export?format=csv&gid=0"
curl -L -o "source.csv" -H "Authorization: Bearer $ACCESS_TOKEN" "$csv_url"

0 comments on commit f6e425c

Please sign in to comment.