|
| 1 | +name: Download illustrations from Figma |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + download_type: |
| 7 | + description: "What to download" |
| 8 | + required: true |
| 9 | + default: "everything" |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - everything |
| 13 | + - ehlds-only |
| 14 | + - icons-only |
| 15 | + specific_ehlds: |
| 16 | + description: "Specific EHLDs to download (space separated, e.g. R-HSA-1234567 R-HSA-9876543). Leave blank for all." |
| 17 | + required: false |
| 18 | + default: "" |
| 19 | + specific_icons: |
| 20 | + description: "Specific icons to download (space separated, e.g. R-ICO-012345 R-ICO-012346). Leave blank for all." |
| 21 | + required: false |
| 22 | + default: "" |
| 23 | + |
| 24 | +jobs: |
| 25 | + download: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: write |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + ref: ${{ github.ref }} |
| 34 | + fetch-depth: 0 |
| 35 | + |
| 36 | + # If triggered from main, create a new branch |
| 37 | + - name: Create new branch if on main |
| 38 | + if: github.ref == 'refs/heads/main' |
| 39 | + run: | |
| 40 | + TIMESTAMP=$(date +'%Y-%m-%d-%H%M') |
| 41 | + BRANCH="figma-download-${TIMESTAMP}" |
| 42 | + git checkout -b "$BRANCH" |
| 43 | + echo "BRANCH=$BRANCH" >> $GITHUB_ENV |
| 44 | +
|
| 45 | + # If triggered from an existing branch, stay on it |
| 46 | + - name: Stay on current branch |
| 47 | + if: github.ref != 'refs/heads/main' |
| 48 | + run: | |
| 49 | + BRANCH="${GITHUB_REF#refs/heads/}" |
| 50 | + echo "BRANCH=$BRANCH" >> $GITHUB_ENV |
| 51 | +
|
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v5 |
| 54 | + with: |
| 55 | + python-version: "3.x" |
| 56 | + |
| 57 | + - name: Install dependencies |
| 58 | + run: pip install requests |
| 59 | + |
| 60 | + # Build the command based on inputs |
| 61 | + - name: Download from Figma |
| 62 | + env: |
| 63 | + FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }} |
| 64 | + run: | |
| 65 | + CMD="python3 download_illustrations.py --skip-validation" |
| 66 | +
|
| 67 | + if [ "${{ inputs.download_type }}" = "ehlds-only" ]; then |
| 68 | + CMD="$CMD --ehlds" |
| 69 | + if [ -n "${{ inputs.specific_ehlds }}" ]; then |
| 70 | + CMD="$CMD --only ${{ inputs.specific_ehlds }}" |
| 71 | + fi |
| 72 | + elif [ "${{ inputs.download_type }}" = "icons-only" ]; then |
| 73 | + CMD="$CMD --icons" |
| 74 | + if [ -n "${{ inputs.specific_icons }}" ]; then |
| 75 | + CMD="$CMD --only-icons ${{ inputs.specific_icons }}" |
| 76 | + fi |
| 77 | + fi |
| 78 | + # If everything, no extra flags needed |
| 79 | +
|
| 80 | + echo "Running: $CMD" |
| 81 | + $CMD |
| 82 | +
|
| 83 | + - name: Commit downloaded files |
| 84 | + run: | |
| 85 | + git config user.name "github-actions[bot]" |
| 86 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 87 | + git add icons/ ehld/ |
| 88 | + if git diff --staged --quiet; then |
| 89 | + echo "No changes to commit" |
| 90 | + else |
| 91 | + git commit -m "Download illustrations from Figma (${{ inputs.download_type }}) $(date +'%Y-%m-%d %H:%M')" |
| 92 | + git push origin "$BRANCH" |
| 93 | + fi |
| 94 | +
|
| 95 | + - name: Validate illustrations |
| 96 | + run: | |
| 97 | + docker run --rm \ |
| 98 | + -v ${{ github.workspace }}/icons:/data/icons \ |
| 99 | + -v ${{ github.workspace }}/ehld:/data/ehld \ |
| 100 | + public.ecr.aws/reactome/illustration-validator:latest \ |
| 101 | + java -jar ./target/illustration-validator-jar-with-dependencies.jar \ |
| 102 | + -e false \ |
| 103 | + -d /data/icons \ |
| 104 | + -s /data/ehld |
| 105 | + continue-on-error: true |
| 106 | + |
| 107 | + - name: Print branch info |
| 108 | + run: | |
| 109 | + echo "==============================" |
| 110 | + echo "Branch: $BRANCH" |
| 111 | + echo "Check validation results above" |
| 112 | + echo "If validation passed, open a pull request to main" |
| 113 | + echo "If validation failed, fix issues on the branch and re-run validation" |
| 114 | + echo "==============================" |
0 commit comments