-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.75 KB
/
call_fts3.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Forked from eKatchko/public-bioinformatics-databases
name: Process changed files
# Controls when the workflow will run
on:
pull_request:
types: [opened, edited, reopened]
branches:
- 'main'
paths:
- 'databases/**.json'
workflow_dispatch:
inputs:
base:
type: string
default: main
required: true
head:
type: string
required: true
jobs:
# This workflow contains a single job called "changed-files"
changed-files:
# The type of runner that the job will run on
runs-on: [self-hosted, fts3-client-production ]
environment: APPROVAL_REQUIRED
outputs:
changed_files: ${{ steps.create-matrix.outputs.matrix }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
id: last_successful_commit_push
with:
main-branch-name: ${{ github.base_ref || github.event.inputs.base }}
workflow-id: 'test.yml'
- name: Run changed-files with the commit of the last successful test workflow run
id: changed-files-base-sha-push
uses: tj-actions/changed-files@v39
with:
base_sha: ${{ steps.last_successful_commit_push.outputs.base }}
files: |
databases/*.json
files_ignore: databases/database_schema.json
- name: Create matrix from changed files
id: create-matrix
run: |
if [[ -n "${{ steps.changed-files.outputs.all_files }}" ]]; then
echo "matrix=$(echo "${{ steps.changed-files.outputs.all_files }}" | tr '\n' ',')" >> $GITHUB_OUTPUT
else
echo "matrix=" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Get changed files with git diff and send to fts3-connector
id: git-diff
run: |
declare -a CHANGED=($(git diff --name-only -r origin/${{ github.base_ref || github.event.inputs.base }} origin/${{ github.head_ref || github.event.inputs.head }} | grep databases/**))
for file in "${CHANGED[@]}"; do
echo "Calling with $file"
curl -H "X-AUTH-HEADER: ${{ secrets.FTS3_CLIENT_API_KEY }}" -H "Content-Type: application/json" -X POST -d @$file "${{ vars.FTS3_CLIENT_ENDPOINT }}/transfer/dry"
done
validate_changed_jsons:
needs: changed-files
strategy:
fail-fast: false
matrix:
FILENAME: ${{ needs.changed-files.outputs.changed_files}}
uses: ./.github/workflows/validate_database_json.yml
with:
FILENAME: ${{ matrix.FILENAME }}
secrets: inherit