GitHub Action "composite" type not working in other repositories due to missing action files

75 Views Asked by At

I've created a GitHub Action for building Anki cards from Markdown files, and I'm using the "composite" type in my action.yml. However, when I run this action in another repository, it's not working because it doesn't have its own action files.

Here's my action.yml:

name: 'anki-action'
description: 'Build anki cards from .md files'
branding:
  icon: alert-triangle
  color: orange
runs:
  using: 'composite'
  steps:
    - run: ls -la
      shell: bash
    - run: ${{ github.action_path }}/entry.sh ${{ inputs.path }}
      shell: bash
    - uses: actions/upload-artifact@v2
      with:
        name: anki-cards
        path: /home/runner/work/anki-action/anki-action/anki-cards/cards.apkg
inputs:
  path:
    description: 'The directory with .md files'
    required: false
    default: 'anki-cards'

And here's my entry.sh:

set -e 
set -x

input_path="${1:-anki-cards}"
cd ${GITHUB_WORKSPACE-/w}
npm i
cd $input_path

ls -la

for filename in $(ls .)
do
  ../node_modules/mdanki/src/index.js $filename cards.apkg
done

I've tried to build Anki cards for LeetCode in this action, but it's not working as expected.

Any help or guidance on how to make this "composite" GitHub Action work in other repositories would be greatly appreciated.

Thank you!

1

There are 1 best solutions below

0
mnst On

Workflow:

name: Build Anki Cards

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout anki-action
        uses: actions/checkout@v2
        with:
          repository: <your username>/anki-action
          path: anki-action

      - name: Run anki-action
        uses: ./anki-action
        with:
          path: leetcode

      - name: Upload artifact
        uses: actions/upload-artifact@v2
        with:
          name: anki-cards
          path: leetcode/cards.apkg

Composite action:

name: 'anki-action'
description: 'Build Anki cards from .md files'
branding:
  icon: alert-triangle
  color: orange
runs:
  using: 'composite'
steps:
  - run: ls -la
    shell: bash

  - run: chmod +x ${{ github.action_path }}/entry.sh
    shell: bash

Useful links: