Wandalen / wretry.action

Retry action for Github CI
MIT License
92 stars 20 forks source link

Error: Cannot read property 'trim' of undefined #64

Closed beyarkay closed 11 months ago

beyarkay commented 1 year ago

Hey!

Thanks for the action, it looks great. I'm trying to use it for a rather complicated use-case, and am getting the error

Error: Cannot read property 'trim' of undefined

Which comes from this line in your source code: https://github.com/Wandalen/wretry.action/blob/master/src/Common.js#L188:

  function jobContextGet()
  {
    const context = Object.create( null );

    if( dockerExists() )
    {
      const containersIds = execSyncNonThrowing( 'docker ps --all --filter status=running --no-trunc --format "{{.ID}}"' );
      const ids = _.strSplit({ src : containersIds.toString(), delimeter : '\n', preservingEmpty : 0 });
      context.container = Object.create( null );
      context.services = Object.create( null );
      for( let i = 0 ; i < ids.length ; i++ )
      {
        const output = execSyncNonThrowing( `docker inspect ${ ids[ i ].trim() }` );  // <---- error here
        const parsed = JSON.parse( output.toString() );
        if( !context.container.network )
        context.container.network = parsed[ 0 ].HostConfig.NetworkMode;

        const service = Object.create( null );
        service.id = parsed[ 0 ].Id;
        service.ports = Object.create( null );
        for( let key in parsed[ 0 ].NetworkSettings.Ports )
        if( parsed[ 0 ].NetworkSettings.Ports[ key ] !== null )
        service.ports[ key.split( '/' )[ 0 ] ] = parsed[ 0 ].NetworkSettings.Ports[ key ][ 0 ].HostPort;
        service.network = context.container.network;

        context.services[ parsed[ 0 ].Args[ 0 ] ] = service;
      }
    }

But I've got no clue about what's happening when it comes to docker containers, so unfortunately this is an issue and not a PR.

Here's the commit where I modified the existing workflow to use your action: https://github.com/beyarkay/eskom-calendar-dev/commit/77bf6dcf4aca9aaf6994ed874cea47e7eddf6fdc

Here's the lines in the github workflow files where I'm using your action: https://github.com/beyarkay/eskom-calendar-dev/blob/main/.github/workflows/publish-calendars.yaml#L59-L111

Here's the run where I got the error: https://github.com/beyarkay/eskom-calendar-dev/actions/runs/3157204705/jobs/5137784537#step:10:56

I have a feeling that, because I've embedded a string inside the embeded string (see the body key and value in my action) that yaml might be getting confused? But this doesn't really match with the error as far as I can see.

beyarkay commented 1 year ago

Okay so I changed the multi-line string body to a single line, and it looks like the resulting step is working as expected.

I'm not entirely sure what to do though, because that multiline string is pretty essential.

dmvict commented 1 year ago

Hello, @beyarkay

I think that your repository escom-calendar-dev has private privilegues. I have no access to it.

Please, write snippets from the workflow and I will investigate the problem.

beyarkay commented 1 year ago

Ah sorry you're right, it's my test environment for eskom-calendar which is the production environment. I'll send through snippets now

beyarkay commented 1 year ago

Here's the workflow that succeeds (maybe because body isn't a multiline string?)

name: Build and Publish Calendars

on:
  push:
    branches: [ "main" ]
    paths:
      - 'manually_specified.yaml'
      - 'src/*.rs'
      - 'src/*.py'
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  build-and-publish-calendars:
    runs-on: ubuntu-latest
    steps:

    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Cache dependencies
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/bin/
          ~/.cargo/registry/index/
          ~/.cargo/registry/cache/
          ~/.cargo/git/db/
          target/
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

    - name: Pip install requirements
      uses: BSFishy/pip-action@v1
      with:
        requirements: requirements.txt

    - name: Cargo build
      uses: actions-rs/cargo@v1
      with:
        command: build
        args: --release

    - name: Cargo run
      uses: actions-rs/cargo@v1
      with:
        command: run
        args: --release

    - name: Write current time stamp to GH variable
      id: date
      run: echo "::set-output name=datetime::$(date +'%Y-%m-%dT%H:%M:%S')"

    - name: List all calendars to GH variable
      run: echo "::set-output name=LS_CALENDARS::$(ls calendars/* | xargs echo | sed 's/ /,/g')"
      id: LS-CALENDARS

      # =========================
      # wretry.action STARTS HERE
      # =========================

    - name: Update latest release with new calendars, retrying if needed
      uses: Wandalen/wretry.action@v1.0.11
      with:
        attempt_limit: 5    # Retry up to 5 times
        attempt_delay: 5000 # Wait 5 seconds between attempts
        action: beyarkay/update-existing-release@master
        with: |
          token: ${{ secrets.GH_ACTIONS_PAT }}
          release: Latest Eskom Loadshedding Calendars
          updateTag: true
          tag: latest
          replace: true
          body: "This is the body"
          files: ${{ steps.LS-CALENDARS.outputs.LS_CALENDARS }}

And here's the action that fails, maybe because of the multiline string:

name: Build and Publish Calendars

on:
  push:
    branches: [ "main" ]
    paths:
      - 'manually_specified.yaml'
      - 'src/*.rs'
      - 'src/*.py'
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  build-and-publish-calendars:
    runs-on: ubuntu-latest
    steps:

    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Cache dependencies
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/bin/
          ~/.cargo/registry/index/
          ~/.cargo/registry/cache/
          ~/.cargo/git/db/
          target/
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

    - name: Pip install requirements
      uses: BSFishy/pip-action@v1
      with:
        requirements: requirements.txt

    - name: Cargo build
      uses: actions-rs/cargo@v1
      with:
        command: build
        args: --release

    - name: Cargo run
      uses: actions-rs/cargo@v1
      with:
        command: run
        args: --release

    - name: Write current time stamp to GH variable
      id: date
      run: echo "::set-output name=datetime::$(date +'%Y-%m-%dT%H:%M:%S')"

    - name: List all calendars to GH variable
      run: echo "::set-output name=LS_CALENDARS::$(ls calendars/* | xargs echo | sed 's/ /,/g')"
      id: LS-CALENDARS

    - name: Update latest release with new calendars, retrying if needed
      uses: Wandalen/wretry.action@v1.0.11
      with:
        attempt_limit: 5    # Retry up to 5 times
        attempt_delay: 5000 # Wait 5 seconds between attempts
        action: beyarkay/update-existing-release@master
        with: |
          token: ${{ secrets.GH_ACTIONS_PAT }}
          release: Latest Eskom Loadshedding Calendars
          updateTag: true
          tag: latest
          replace: true
          files: ${{ steps.LS-CALENDARS.outputs.LS_CALENDARS }}
          body: "# To get your load shedding schedule in your calendar:
            1. Scroll down to the blue links under `Assets`:
            ![Assets image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/assets.png)
            2. Find the `ics` calendar file corresponding to your area (use ctrl-f to search quickly).
            3. Right-click on the file and copy the link:
            ![Right click and copy image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/copy-link.png)
            4. Open your calendar app (Google Calendar, Outlook, Apple Calendar, etc)
            5. Paste the calendar link in your app's `subscribe to calendar` option.
            | [Google Calendar](https://calendar.google.com/calendar/u/0/r/settings/addbyurl)  | [Outlook](https://outlook.office.com/calendar/addcalendar) | [Apple Calendar](https://support.apple.com/en-za/guide/calendar/icl1022/mac) |
            | ----------------- | --------------- | --------------- |
            | ![google calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/gcal.png) | ![outlook subscripition image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/outlook.png) | ![apple calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/ical.png) |
            That's it! 
            ### Details
            Now you've got loadshedding warnings in your calendar that tell you if the power will be off or not. This is better than apps like EskomSePush because it combines what area you're in with your area's loadshedding schedule. You'll only be notified if
            1. there's national loadshedding announced by Eskom *and*
            2. your area has loadshedding scheduled for that time.
            ### Developers
            There's also a machine-friendly csv file that contains loadshedding information. Have a look at the [`README.md`](https://github.com/beyarkay/eskom-calendar/tree/latest) for ideas!
            Last updated: ${{ steps.date.outputs.datetime }} UTC"

And here's the full message from the retry workflow step:

Run Wandalen/wretry.action@v1.0.11
  with:
    attempt_limit: 5
    attempt_delay: 5000
    action: beyarkay/update-existing-release@master
    with: token: ***
  release: Latest Eskom Loadshedding Calendars
  updateTag: true
  tag: latest
  replace: true
  files: calendars/city-of-cape-town-area-1.ics,calendars/city-of-cape-town-area-10.ics,calendars/city-of-cape-town-area-11.ics,calendars/city-of-cape-town-area-12.ics,calendars/city-of-cape-town-area-13.ics,calendars/city-of-cape-town-area-14.ics,calendars/city-of-cape-town-area-15.ics,calendars/city-of-cape-town-area-16.ics,calendars/city-of-cape-town-area-2.ics,calendars/city-of-cape-town-area-3.ics,calendars/city-of-cape-town-area-4.ics,calendars/city-of-cape-town-area-5.ics,calendars/city-of-cape-town-area-6.ics,calendars/city-of-cape-town-area-7.ics,calendars/city-of-cape-town-area-8.ics,calendars/city-of-cape-town-area-9.ics,calendars/city-power-1.ics,calendars/city-power-10.ics,calendars/city-power-11.ics,calendars/city-power-12.ics,calendars/city-power-13.ics,calendars/city-power-14.ics,calendars/city-power-15.ics,calendars/city-power-16.ics,calendars/city-power-2.ics,calendars/city-power-3.ics,calendars/city-power-4.ics,calendars/city-power-5.ics,calendars/city-power-6.ics,calendars/city-power-7.ics,calendars/city-power-8.ics,calendars/city-power-9.ics,calendars/eastern-cape-adelaide.ics,calendars/eastern-cape-arbedeen.ics,calendars/eastern-cape-barklyeast.ics,calendars/eastern-cape-bathurst.ics,calendars/eastern-cape-bedford.ics,calendars/eastern-cape-burgersdorp.ics,calendars/eastern-cape-butterworth.ics,calendars/eastern-cape-capestfrancisbay.ics,calendars/eastern-cape-cathcart.ics,calendars/eastern-cape-cradock.ics,calendars/eastern-cape-dordrecht.ics,calendars/eastern-cape-dutywa.ics,calendars/eastern-cape-elliot.ics,calendars/eastern-cape-george.ics,calendars/eastern-cape-graaf-reinet.ics,calendars/eastern-cape-grahamstown.ics,calendars/eastern-cape-hofmeyer.ics,calendars/eastern-cape-humansdorp.ics,calendars/eastern-cape-indwe.ics,calendars/eastern-cape-jansenville.ics,calendars/eastern-cape-jeffreysbay.ics,calendars/eastern-cape-kareedouw.ics,calendars/eastern-cape-kirkwood.ics,calendars/eastern-cape-komga.ics,calendars/eastern-cape-ladygrey.ics,calendars/eastern-cape-maclear.ics,calendars/eastern-cape-marselle.ics,calendars/eastern-cape-matatiele.ics,calendars/eastern-cape-mbizana.ics,calendars/eastern-cape-middelburg.ics,calendars/eastern-cape-molteno.ics,calendars/eastern-cape-mthatha.ics,calendars/eastern-cape-oviston.ics,calendars/eastern-cape-peddie.ics,calendars/eastern-cape-portalfred.ics,calendars/eastern-cape-queenstown.ics,calendars/eastern-cape-sommerseteast.ics,calendars/eastern-cape-sterkskroon.ics,calendars/eastern-cape-steytlertville.ics,calendars/eastern-cape-stfrancisbay.ics,calendars/eastern-cape-stutterheim.ics,calendars/eastern-cape-tarkastad.ics,calendars/eastern-cape-teebus.ics,calendars/eastern-cape-ugie.ics,calendars/eastern-cape-umtata.ics,calendars/eastern-cape-venterstad.ics,calendars/eastern-cape-willowmore.ics,calendars/free-state-allanridge.ics,calendars/free-state-bethlehem.ics,calendars/free-state-bethulie.ics,calendars/free-state-boshof.ics,calendars/free-state-bothaville.ics,calendars/free-state-brandfort.ics,calendars/free-state-bultfontein.ics,calendars/free-state-clocolan.ics,calendars/free-state-cornelia.ics,calendars/free-state-dealesville.ics,calendars/free-state-deneysville.ics,calendars/free-state-dewetsdorp.ics,calendars/free-state-edenburg.ics,calendars/free-state-edenville.ics,calendars/free-state-ek-ondv-van-alice.ics,calendars/free-state-excelsior.ics,calendars/free-state-ezenzeleni.ics,calendars/free-state-fatengtshentsho.ics,calendars/free-state-fauresmigh.ics,calendars/free-state-ficksburg.ics,calendars/free-state-flamingo.ics,calendars/free-state-fouriesburg.ics,calendars/free-state-frankfort.ics,calendars/free-state-gariep.ics,calendars/free-state-groenvoerlande.ics,calendars/free-state-harrismith.ics,calendars/free-state-heilbron.ics,calendars/free-state-hennenman.ics,calendars/free-state-hertzogville.ics,calendars/free-state-hoopstad.ics,calendars/free-state-ipopeng.ics,calendars/free-state-jagersfontein.ics,calendars/free-state-kestell.ics,calendars/free-state-koffiefontein.ics,calendars/free-state-koppies.ics,calendars/free-state-kroonstad.ics,calendars/free-state-ladybrand.ics,calendars/free-state-lesotho.ics,calendars/free-state-lindley.ics,calendars/free-state-luckhof.ics,calendars/free-state-marquad.ics,calendars/free-state-matoporong.ics,calendars/free-state-naleditownship.ics,calendars/free-state-ngwathemunic.ics,calendars/free-state-odendaalsrus.ics,calendars/free-state-oranjeville.ics,calendars/free-state-panorama.ics,calendars/free-state-parys.ics,calendars/free-state-paulroux.ics,calendars/free-state-petrusburg.ics,calendars/free-state-petrussteyn.ics,calendars/free-state-philipolis.ics,calendars/free-state-phiritona.ics,calendars/free-state-phutaditjhaba.ics,calendars/free-state-qwa-qwa.ics,calendars/free-state-reddersburg.ics,calendars/free-state-reitz.ics,calendars/free-state-riebeeckstad.ics,calendars/free-state-rosendal.ics,calendars/free-state-rouxville.ics,calendars/free-state-rweleleyathunya.ics,calendars/free-state-senekal.ics,calendars/free-state-seretse.ics,calendars/free-state-smithfield.ics,calendars/free-state-springfonteintown.ics,calendars/free-state-springfonteintruck(garage).ics,calendars/free-state-steynsrus.ics,calendars/free-state-theunissen.ics,calendars/free-state-trompsburg.ics,calendars/free-state-tsheseng.ics,calendars/free-state-tshiame.ics,calendars/free-state-tweeling.ics,calendars/free-state-tweespruit.ics,calendars/free-state-vaalpark.ics,calendars/free-state-vanstandensrus.ics,calendars/free-state-veerkerde-vlei.ics,calendars/free-state-ventersburg.ics,calendars/free-state-viljoenskroon.ics,calendars/free-state-villiers.ics,calendars/free-state-virginianorth.ics,calendars/free-state-virginiatown.ics,calendars/free-state-vredefort.ics,calendars/free-state-w.ics,calendars/free-state-warden.ics,calendars/free-state-welkombulk.ics,calendars/free-state-welkomtown.ics,calendars/free-state-wepener.ics,calendars/free-state-wesselsbron.ics,calendars/free-state-winburg.ics,calendars/free-state-witsiekhoek.ics,calendars/free-state-zamdela.ics,calendars/free-state-zastron.ics,calendars/gauteng-ekurhuleni-block-1.ics,calendars/gauteng-ekurhuleni-block-10.ics,calendars/gauteng-ekurhuleni-block-11.ics,calendars/gauteng-ekurhuleni-block-12.ics,calendars/gauteng-ekurhuleni-block-13.ics,calendars/gauteng-ekurhuleni-block-14.ics,calendars/gauteng-ekurhuleni-block-15.ics,calendars/gauteng-ekurhuleni-block-16.ics,calendars/gauteng-ekurhuleni-block-2.ics,calendars/gauteng-ekurhuleni-block-3.ics,calendars/gauteng-ekurhuleni-block-4.ics,calendars/gauteng-ekurhuleni-block-5.ics,calendars/gauteng-ekurhuleni-block-6.ics,calendars/gauteng-ekurhuleni-block-7.ics,calendars/gauteng-ekurhuleni-block-8.ics,calendars/gauteng-ekurhuleni-block-9.ics,calendars/gauteng-tshwane-group-1.ics,calendars/gauteng-tshwane-group-10.ics,calendars/gauteng-tshwane-group-11.ics,calendars/gauteng-tshwane-group-12.ics,calendars/gauteng-tshwane-group-13.ics,calendars/gauteng-tshwane-group-14.ics,calendars/gauteng-tshwane-group-15.ics,calendars/gauteng-tshwane-group-16.ics,calendars/gauteng-tshwane-group-2.ics,calendars/gauteng-tshwane-group-3.ics,calendars/gauteng-tshwane-group-4.ics,calendars/gauteng-tshwane-group-5.ics,calendars/gauteng-tshwane-group-6.ics,calendars/gauteng-tshwane-group-7.ics,calendars/gauteng-tshwane-group-8.ics,calendars/gauteng-tshwane-group-9.ics,calendars/kwazulu-natal-ballito.ics,calendars/kwazulu-natal-dundee.ics,calendars/kwazulu-natal-eshowe.ics,calendars/kwazulu-natal-fleetwood.ics,calendars/kwazulu-natal-glencoe.ics,calendars/kwazulu-natal-greytown.ics,calendars/kwazulu-natal-harding.ics,calendars/kwazulu-natal-howick.ics,calendars/kwazulu-natal-kodstad.ics,calendars/kwazulu-natal-mandeni.ics,calendars/kwazulu-natal-mpofana.ics,calendars/kwazulu-natal-mpomphomeni.ics,calendars/kwazulu-natal-mthonjaneni.ics,calendars/kwazulu-natal-newcastle.ics,calendars/kwazulu-natal-northern.ics,calendars/kwazulu-natal-nquthu.ics,calendars/kwazulu-natal-paulpietersburg.ics,calendars/kwazulu-natal-raynkonyeni.ics,calendars/kwazulu-natal-southern.ics,calendars/kwazulu-natal-stanger.ics,calendars/kwazulu-natal-ulundi.ics,calendars/kwazulu-natal-umvoti.ics,calendars/kwazulu-natal-uphongolo.ics,calendars/kwazulu-natal-utrecht.ics,calendars/limpopo-addney.ics,calendars/limpopo-alldays-dorp.ics,calendars/limpopo-arrie.ics,calendars/limpopo-bayswater.ics,calendars/limpopo-belabelatown.ics,calendars/limpopo-diepsloot.ics,calendars/limpopo-esoringa.ics,calendars/limpopo-genoa.ics,calendars/limpopo-gideon.ics,calendars/limpopo-goedetrou.ics,calendars/limpopo-grobblersdaltown.ics,calendars/limpopo-innes.ics,calendars/limpopo-kgapane(duiwelskloof)_town.ics,calendars/limpopo-kgatla.ics,calendars/limpopo-lephalale(ellisras)_town.ics,calendars/limpopo-lesedingtownship.ics,calendars/limpopo-magari.ics,calendars/limpopo-makhado(louis_trichardt)_town.ics,calendars/limpopo-marblehalltown.ics,calendars/limpopo-modimollenystroomtown.ics,calendars/limpopo-mohwadi(dendron)_town.ics,calendars/limpopo-mokhurumela.ics,calendars/limpopo-mokopane(potgieterus)town.ics,calendars/limpopo-montz.ics,calendars/limpopo-mookgophong(naboomspruit).ics,calendars/limpopo-mosehleng.ics,calendars/limpopo-musinatown.ics,calendars/limpopo-nancefieldtownship.ics,calendars/limpopo-normandy.ics,calendars/limpopo-phagamengtownship.ics,calendars/limpopo-phalaborwatown.ics,calendars/limpopo-rooiberg.ics,calendars/limpopo-simson.ics,calendars/limpopo-swart.ics,calendars/limpopo-sweethome.ics,calendars/limpopo-thabazimbitown.ics,calendars/limpopo-thegrench.ics,calendars/limpopo-vaalwatertown.ics,calendars/limpopo-witten.ics,calendars/machine_friendly.csv,calendars/mpumalanga-aerorand.ics,calendars/mpumalanga-barberton.ics,calendars/mpumalanga-bethal.ics,calendars/mpumalanga-buffelspruit.ics,calendars/mpumalanga-camcoll.ics,calendars/mpumalanga-clever.ics,calendars/mpumalanga-cohen.ics,calendars/mpumalanga-cologne.ics,calendars/mpumalanga-delta.ics,calendars/mpumalanga-doornpoort.ics,calendars/mpumalanga-dryden-rural.ics,calendars/mpumalanga-ermelo.ics,calendars/mpumalanga-estancia.ics,calendars/mpumalanga-figtree.ics,calendars/mpumalanga-greyslingstad.ics,calendars/mpumalanga-highlands.ics,calendars/mpumalanga-jerusalem.ics,calendars/mpumalanga-kabokweni.ics,calendars/mpumalanga-kanyamazani.ics,calendars/mpumalanga-kemp.ics,calendars/mpumalanga-kiepersol.ics,calendars/mpumalanga-klipspringer.ics,calendars/mpumalanga-komatipoort.ics,calendars/mpumalanga-koorsboom.ics,calendars/mpumalanga-kwa-guqa.ics,calendars/mpumalanga-louwscreek.ics,calendars/mpumalanga-lyndenburg.ics,calendars/mpumalanga-malelane.ics,calendars/mpumalanga-marathon.ics,calendars/mpumalanga-mataffin_sub.ics,calendars/mpumalanga-middelburg.ics,calendars/mpumalanga-nelsriver_sub.ics,calendars/mpumalanga-nkomazi.ics,calendars/mpumalanga-ogies.ics,calendars/mpumalanga-piet-retief.ics,calendars/mpumalanga-sappi.ics,calendars/mpumalanga-secunda.ics,calendars/mpumalanga-sol.ics,calendars/mpumalanga-standerton.ics,calendars/mpumalanga-sundra.ics,calendars/mpumalanga-usuthu-west.ics,calendars/mpumalanga-vukuzakhe.ics,calendars/mpumalanga-whiteriver.ics,calendars/mpumalanga-wildebees.ics,calendars/mpumalanga-witbank_ds.ics,calendars/north-west-boikhutso.ics,calendars/north-west-coligny.ics,calendars/north-west-delareyville.ics,calendars/north-west-gumtrees.ics,calendars/north-west-hartebeesfontein.ics,calendars/north-west-jouberton.ics,calendars/north-west-klerksdorpmunic.ics,calendars/north-west-klerksdorpnorth.ics,calendars/north-west-klerksdorpwest.ics,calendars/north-west-koster.ics,calendars/north-west-leeudoringstad.ics,calendars/north-west-lichtenburg.ics,calendars/north-west-orkneymunic.ics,calendars/north-west-ottosdal.ics,calendars/north-west-potchefstroom.ics,calendars/north-west-sannieshof.ics,calendars/north-west-schweizer-reneke.ics,calendars/north-west-stillfontein.ics,calendars/north-west-swartruggens.ics,calendars/north-west-ventersdorp.ics,calendars/north-west-vryburg.ics,calendars/north-west-waterworkspoints.ics,calendars/north-west-wolmaranstad.ics,calendars/north-west-woodhouse.ics,calendars/north-west-zeerust.ics,calendars/northern-cape-alexanderbay.ics,calendars/northern-cape-augrabies.ics,calendars/northern-cape-backlywest.ics,calendars/northern-cape-bitterfontein.ics,calendars/northern-cape-brandvlei.ics,calendars/northern-cape-britstown.ics,calendars/northern-cape-calvinia.ics,calendars/northern-cape-carnarvon.ics,calendars/northern-cape-christiana.ics,calendars/northern-cape-colesberg.ics,calendars/northern-cape-danielskuil.ics,calendars/northern-cape-de-aar.ics,calendars/northern-cape-deben.ics,calendars/northern-cape-delsportshoop.ics,calendars/northern-cape-dingleton.ics,calendars/northern-cape-douglas.ics,calendars/northern-cape-fraserburg.ics,calendars/northern-cape-goodhouse.ics,calendars/northern-cape-groblershoop.ics,calendars/northern-cape-hanover.ics,calendars/northern-cape-hopetown.ics,calendars/northern-cape-jankempdorp.ics,calendars/northern-cape-kakamas.ics,calendars/northern-cape-kamieskroon.ics,calendars/northern-cape-kathu.ics,calendars/northern-cape-keimoes.ics,calendars/northern-cape-kenhardt.ics,calendars/northern-cape-koekenaap.ics,calendars/northern-cape-kuruman.ics,calendars/northern-cape-loeriesfontein.ics,calendars/northern-cape-loxton.ics,calendars/northern-cape-lutzville.ics,calendars/northern-cape-merweville.ics,calendars/northern-cape-nelspoort.ics,calendars/northern-cape-nieuwoudtville.ics,calendars/northern-cape-norvalspont.ics,calendars/northern-cape-noupoort.ics,calendars/northern-cape-okiep.ics,calendars/northern-cape-oliefantshoek.ics,calendars/northern-cape-petrusville.ics,calendars/northern-cape-phillipstown.ics,calendars/northern-cape-port-nolloth.ics,calendars/northern-cape-potsmasburgindustry.ics,calendars/northern-cape-potsmasburgtown.ics,calendars/northern-cape-prieska.ics,calendars/northern-cape-richmond.ics,calendars/northern-cape-rietpoort.ics,calendars/northern-cape-springbok.ics,calendars/northern-cape-steinkopf.ics,calendars/northern-cape-upington.ics,calendars/northern-cape-vanderkloof.ics,calendars/northern-cape-vanwyskvlei.ics,calendars/northern-cape-victoriawest.ics,calendars/northern-cape-vioolsdrift.ics,calendars/northern-cape-vosburg.ics,calendars/northern-cape-warrenton.ics,calendars/northern-cape-willinston.ics,calendars/western-cape-albertinia.ics,calendars/western-cape-arniston.ics,calendars/western-cape-ashton.ics,calendars/western-cape-barrydale.ics,calendars/western-cape-beaufort-west.ics,calendars/western-cape-betties-bay.ics,calendars/western-cape-bonnievale.ics,calendars/western-cape-botrivier.ics,calendars/western-cape-bredasdorp.ics,calendars/western-cape-caledon.ics,calendars/western-cape-calitzdorp.ics,calendars/western-cape-ceres.ics,calendars/western-cape-citrusdal.ics,calendars/western-cape-clanwilliam.ics,calendars/western-cape-darling.ics,calendars/western-cape-de-doorns.ics,calendars/western-cape-derust.ics,calendars/western-cape-dysselsdorp.ics,calendars/western-cape-elandsbaai.ics,calendars/western-cape-franschoek.ics,calendars/western-cape-gansbaai.ics,calendars/western-cape-genadendal.ics,calendars/western-cape-george.ics,calendars/western-cape-glentana.ics,calendars/western-cape-goedverwacht.ics,calendars/western-cape-gouda.ics,calendars/western-cape-graaf-water.ics,calendars/western-cape-grabouw.ics,calendars/western-cape-greyton.ics,calendars/western-cape-grootbrak.ics,calendars/western-cape-hawston.ics,calendars/western-cape-heidelburg.ics,calendars/western-cape-herbetsdal.ics,calendars/western-cape-hermanus.ics,calendars/western-cape-hopeful.ics,calendars/western-cape-infanta.ics,calendars/western-cape-klawer.ics,calendars/western-cape-kleinbrak.ics,calendars/western-cape-kleinmond.ics,calendars/western-cape-klipdale.ics,calendars/western-cape-knysna.ics,calendars/western-cape-ladismith.ics,calendars/western-cape-laingsburg.ics,calendars/western-cape-lambertsbaai.ics,calendars/western-cape-langebaan.ics,calendars/western-cape-lutzville.ics,calendars/western-cape-malgas.ics,calendars/western-cape-malmesbury.ics,calendars/western-cape-mcgregor.ics,calendars/western-cape-montagu.ics,calendars/western-cape-moorreesbury.ics,calendars/western-cape-mossel-bay.ics,calendars/western-cape-napier.ics,calendars/western-cape-noree.ics,calendars/western-cape-oudtshoorn.ics,calendars/western-cape-paternoster.ics,calendars/western-cape-piketberg.ics,calendars/western-cape-plettenberg-bay.ics,calendars/western-cape-porterville.ics,calendars/western-cape-princealberttown.ics,calendars/western-cape-pringle-bay.ics,calendars/western-cape-protem.ics,calendars/western-cape-rheenendal.ics,calendars/western-cape-riebeeck-kasteel.ics,calendars/western-cape-riebeeck-west.ics,calendars/western-cape-riversdale.ics,calendars/western-cape-riviersonderend.ics,calendars/western-cape-robertson.ics,calendars/western-cape-saldanahbay.ics,calendars/western-cape-stanford.ics,calendars/western-cape-stellenbosch.ics,calendars/western-cape-sthelenabay.ics,calendars/western-cape-stompeus-bay.ics,calendars/western-cape-struisbaai.ics,calendars/western-cape-sutherland.ics,calendars/western-cape-suurbraak.ics,calendars/western-cape-swellendam.ics,calendars/western-cape-tesselaarsdal.ics,calendars/western-cape-till-bay.ics,calendars/western-cape-touwsrivier.ics,calendars/western-cape-tulbagh.ics,calendars/western-cape-van-rhynsdorp.ics,calendars/western-cape-vanwyksdorp.ics,calendars/western-cape-velddrift.ics,calendars/western-cape-villiersdorp.ics,calendars/western-cape-vleesbaai.ics,calendars/western-cape-vredenburg.ics,calendars/western-cape-vredendal.ics,calendars/western-cape-wellington.ics,calendars/western-cape-witsand.ics,calendars/western-cape-wolseley.ics,calendars/western-cape-worscester.ics,calendars/western-cape-yzerfontein.ics,calendars/western-cape-zoar.ics
  body: "# To get your load shedding schedule in your calendar:

    1. Scroll down to the blue links under `Assets`:

    ![Assets image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/assets.png)

    2. Find the `ics` calendar file corresponding to your area (use ctrl-f to search quickly).

    3. Right-click on the file and copy the link:

    ![Right click and copy image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/copy-link.png)

    4. Open your calendar app (Google Calendar, Outlook, Apple Calendar, etc)

    5. Paste the calendar link in your app's `subscribe to calendar` option.

    | [Google Calendar](https://calendar.google.com/calendar/u/0/r/settings/addbyurl)  | [Outlook](https://outlook.office.com/calendar/addcalendar) | [Apple Calendar](https://support.apple.com/en-za/guide/calendar/icl1022/mac) |

    | ----------------- | --------------- | --------------- |

    | ![google calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/gcal.png) | ![outlook subscripition image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/outlook.png) | ![apple calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/ical.png) |

    That's it! 

    ### Details

    Now you've got loadshedding warnings in your calendar that tell you if the power will be off or not. This is better than apps like EskomSePush because it combines what area you're in with your area's loadshedding schedule. You'll only be notified if

    1. there's national loadshedding announced by Eskom *and*

    2. your area has loadshedding scheduled for that time.

    ### Developers

    There's also a machine-friendly csv file that contains loadshedding information. Have a look at the [`README.md`](https://github.com/beyarkay/eskom-calendar/tree/latest) for ideas!

    Last updated: 2022-09-30T08:06:41 UTC"

  env:
    CARGO_TERM_COLOR: always
Error: Cannot read property 'trim' of undefined
dmvict commented 1 year ago

@beyarkay

It is restriction of the action. Each line of the field with is interpreted as the pair key-value (see description of the field with). Now you can use only single-line value.

I will try to extend action to handle such cases correctly.

beyarkay commented 1 year ago

Hmm okay, thanks for trying to fix it!

dmvict commented 1 year ago

Hello, @beyarkay

I've fixed the problem with multiline strings in #65. The new behavior is tested by the new tests. Also, I manually test it in a test repository.

Code snippet:

      - uses : dmvict/wretry.action@fix
        with:
          action: dmvict/test.action@multiline_option
          with: |
            multiline: |
              one
              two
            string: |
          attempt_limit: 3
          attempt_delay: 2000

And the action works as I expected: зображення

Please, use action Wandalen/wretry.action@master when PR #65 will be merged. Do not use the dmvict/wretry.action@fix because, after the merge the branch fix will be removed.

beyarkay commented 1 year ago

Thanks! any idea when #65 will be merged?

dmvict commented 1 year ago

I think it will be soon. I will report to the owner Wandalen that I opened PR with the fix.

dmvict commented 1 year ago

The PR #65 was merged. You can try to use new version.

beyarkay commented 1 year ago

I've changed my workflow to use 1.0.28, but now I'm getting the error: Error: Expects non-primitive.

Any idea what's causing this?

dmvict commented 1 year ago

I think you are using invalid formatting.

Simplified example:

option: | 
  first string 
  second string 

It is important to write vertical bar in declaration of multiline option and use indentation for each line in multiline option.

beyarkay commented 1 year ago

I can't see any errors in the formatting, but maybe I'm missing something? I uploaded the YAML here and it all seems to be valid. Here's the full file again:

name: Build and Publish Calendars

on:
  push:
    branches: [ "main" ]
    paths:
      - 'manually_specified.yaml'
      - 'src/*.rs'
      - 'src/*.py'
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  build-and-publish-calendars:
    runs-on: ubuntu-latest
    steps:

    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Cache dependencies
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/bin/
          ~/.cargo/registry/index/
          ~/.cargo/registry/cache/
          ~/.cargo/git/db/
          target/
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

    - name: Pip install requirements
      uses: BSFishy/pip-action@v1
      with:
        requirements: requirements.txt

    - name: Cargo build
      uses: actions-rs/cargo@v1
      with:
        command: build
        args: --release

    - name: Cargo run
      uses: actions-rs/cargo@v1
      with:
        command: run
        args: --release

    - name: Write current time stamp to GH variable
      id: date
      run: echo "::set-output name=datetime::$(date +'%Y-%m-%dT%H:%M:%S')"

    - name: List all calendars to GH variable
      run: echo "::set-output name=LS_CALENDARS::$(ls calendars/* | xargs echo | sed 's/ /,/g')"
      id: LS-CALENDARS

    - name: Update latest release with new calendars, retrying if needed
      uses: Wandalen/wretry.action@v1.0.28
      with:
        attempt_limit: 5    # Retry up to 5 times
        attempt_delay: 5000 # Wait 5 seconds between attempts
        action: beyarkay/update-existing-release@master
        with: |
          token: ${{ secrets.GH_ACTIONS_PAT }}
          release: Latest Eskom Loadshedding Calendars
          updateTag: true
          tag: latest
          replace: true
          files: ${{ steps.LS-CALENDARS.outputs.LS_CALENDARS }}
          body: "# To get your load shedding schedule in your calendar:
            1. Scroll down to the blue links under `Assets`:
            ![Assets image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/assets.png)
            2. Find the `ics` calendar file corresponding to your area (use ctrl-f to search quickly).
            3. Right-click on the file and copy the link:
            ![Right click and copy image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/copy-link.png)
            4. Open your calendar app (Google Calendar, Outlook, Apple Calendar, etc).
            5. Paste the calendar link in your app's `subscribe to calendar` option:
            | [Google Calendar](https://calendar.google.com/calendar/u/0/r/settings/addbyurl)  | [Outlook](https://outlook.office.com/calendar/addcalendar) | [Apple Calendar](https://support.apple.com/en-za/guide/calendar/icl1022/mac) |
            | ----------------- | --------------- | --------------- |
            | ![google calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/gcal.png) | ![outlook subscripition image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/outlook.png) | ![apple calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/ical.png) |
            That's it!
            ### Details
            Now you've got loadshedding warnings in your calendar that tell you if the power will be off or not. This is better than apps like EskomSePush because it combines what area you're in with your area's loadshedding schedule. You'll only be notified if
            1. there's national loadshedding announced by Eskom *and*
            2. your area has loadshedding scheduled for that time.
            ### Developers
            There's also a machine-friendly csv file that contains loadshedding information. Have a look at the [`README.md`](https://github.com/beyarkay/eskom-calendar/tree/latest) for ideas!
            Last updated: ${{ steps.date.outputs.datetime }} UTC"
dmvict commented 1 year ago

Sorry, I had some important tasks.

The file is correct. The simplest parser that I implemented uses vertical bar as begin token and indentations as continuation.

Please, replace the action with this code:

    - name: Update latest release with new calendars, retrying if needed
      uses: Wandalen/wretry.action@v1.0.28
      with:
        attempt_limit: 5    # Retry up to 5 times
        attempt_delay: 5000 # Wait 5 seconds between attempts
        action: beyarkay/update-existing-release@master
        with: |
          token: ${{ secrets.GH_ACTIONS_PAT }}
          release: Latest Eskom Loadshedding Calendars
          updateTag: true
          tag: latest
          replace: true
          files: ${{ steps.LS-CALENDARS.outputs.LS_CALENDARS }}
          body: |
            # To get your load shedding schedule in your calendar:
            1. Scroll down to the blue links under `Assets`:
            ![Assets image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/assets.png)
            2. Find the `ics` calendar file corresponding to your area (use ctrl-f to search quickly).
            3. Right-click on the file and copy the link:
            ![Right click and copy image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/copy-link.png)
            4. Open your calendar app (Google Calendar, Outlook, Apple Calendar, etc).
            5. Paste the calendar link in your app's `subscribe to calendar` option:
            | [Google Calendar](https://calendar.google.com/calendar/u/0/r/settings/addbyurl)  | [Outlook](https://outlook.office.com/calendar/addcalendar) | [Apple Calendar](https://support.apple.com/en-za/guide/calendar/icl1022/mac) |
            | ----------------- | --------------- | --------------- |
            | ![google calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/gcal.png) | ![outlook subscripition image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/outlook.png) | ![apple calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/ical.png) |
            That's it!
            ### Details
            Now you've got loadshedding warnings in your calendar that tell you if the power will be off or not. This is better than apps like EskomSePush because it combines what area you're in with your area's loadshedding schedule. You'll only be notified if
            1. there's national loadshedding announced by Eskom *and*
            2. your area has loadshedding scheduled for that time.
            ### Developers
            There's also a machine-friendly csv file that contains loadshedding information. Have a look at the [`README.md`](https://github.com/beyarkay/eskom-calendar/tree/latest) for ideas!
            Last updated: ${{ steps.date.outputs.datetime }} UTC
beyarkay commented 1 year ago

Thanks! I've tried it out and everything's building, except GH wants a newline before and after the table in order for it to render as a table, and not as |---|---|---|. I've added them and am rebuilding now. The edited portion looks like:

5. Paste the calendar link in your app's `subscribe to calendar` option:

| [Google Calendar](https://calendar.google.com/calendar/u/0/r/settings/addbyurl)  | [Outlook](https://outlook.office.com/calendar/addcalendar) | [Apple Calendar](https://support.apple.com/en-za/guide/calendar/icl1022/mac) |
| ----------------- | --------------- | --------------- |
| ![google calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/gcal.png) | ![outlook subscripition image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/outlook.png) | ![apple calendar subscription image](https://github.com/beyarkay/eskom-calendar/blob/main/imgs/ical.png) |

That's it!

EDIT:

Adding regular newlines didn't work, they got dropped I think. I'm now trying the same thing but with regular newlines and \ns as well

kbolino commented 1 year ago

Moving a discussion here from #79 because this issue is more relevant. Is there a way to handle the case when the multiline string in question is from a substituted value, and that value itself contains significant newlines?

Context

Context and examples For example, the [docker/build-push-action](https://github.com/docker/build-push-action) requires a multiline string to pass various options, such as multiple build args. Here's an example with build args: ```yaml - name: Build and push image with retry uses: Wandalen/wretry.action@v1.0.36 with: action: docker/build-push-action@v3 with: | build-args: | alpine_version=3.17 go_version=1.19.6 file: ./Dockerfile pull: true push: true tags: docker.example/some-image:some-tag attempt_limit: 3 attempt_delay: 30000 ``` However, what if the build args parameter itself needs to be variable? It is possible to pass a string value containing newlines directly to the docker action, e.g.: ```yaml - name: Build and push image without retry env: build_args: | alpine_version=3.17 go_version=1.19.6 uses: docker/build-push-action@v3 build-args: ${{ env.build_args }} file: ./Dockerfile pull: true push: true tags: docker.example/some-image:some-tag ``` Here, the value of `env.build_args` is a string containing embedded newlines, and this seems to work fine. But it doesn't seem to be possible to pass the args through retry. Obviously this is a somewhat contrived example, as the `env` is set in the same place as it is used; in practice, this is separated by other steps, jobs, or even `workflow_call` from another workflow.

Results

Table of non-solutions tried and their outcomes Here are the potential solutions I've attempted and the results: | Non-Solution | Result | | :--- | :--- | | control (no retry) | Build invoked with `--build-arg alpine_version=3.17 --build-arg go_version=1.19.6` | | simple | `Error: Expects non-primitive` | | simple-continuation | `Error: Expects non-primitive` | | to-json | Build invoked with `--build-arg alpine_version=3.17\ngo_version=1.19.6\n`, i.e. one argument whose value is the entire rest of the args with literal `\n` sequences instead of newlines | | from-json-join | Similar to to-json except that instead of literal `\n` there's literal `\n` followed by many spaces (but still part of the same argument) | | indent-continuation | This works (!) but requires carefully formatting the value |

Non-Solutions

Illustrations of each non-solution ### simple ```yaml with: | build-args: ${{ env.build_args }} ``` ### simple-continuation ```yaml with: | build-args: | ${{ env.build_args }} ``` ### to-json ```yaml with: | build-args: ${{ toJSON(env.build_args) }} ``` ### from-json-join This one also changes the setup, instead of `env.build_args` being a string with embedded newlines, it's a JSON array of strings. Also, the number of spaces after the `\n` in the `join` call has to match the expected indentation level. ```yaml with: | build-args: | ${{ join(fromJSON(env.build_args), '\n ') }} ``` ### indent-continuation This is the same as simple-continuation except that `env.build_args` has extra indentation on all lines except the first, i.e.: ```yaml env: build_args: | alpine_version=3.17 go_version=1.19.6 ``` This actually does solve the problem but feels hacky and fickle. The extra indentation in the value has to match what's expected later at point of use.
dmvict commented 1 year ago

Hello, @beyarkay

This PR https://github.com/Wandalen/wretry.action/pull/86 should solve the problem with skipping of empty strings.

dmvict commented 1 year ago

Hello, @beyarkay

The new version is released. Please, try version v1.2.0 and give me a feedback.

beyarkay commented 1 year ago

Thanks! Will do when I get a minute

dominicmh commented 11 months ago

@beyarkay, did this fix the issue for you? I noticed that accessing GitHub Actions secrets resulted in the mentioned Error: Expects non-primitive:

- uses: Wandalen/wretry.action@master
  with:
    action: action/foo@1.2.3
    with: |
      bar-option: ${{ secrets.BAR }}
dmvict commented 11 months ago

Hello @dominicmh

I suppose that your secret is a multiline string but the string does not keep indentations. Please, try hardcode the value using example from https://github.com/Wandalen/wretry.action/issues/64#issuecomment-1264993827

dominicmh commented 11 months ago

Thanks for the input, @dmvict! You're right, the secret is a multi-line string.

I wouldn't want to commit the hardcoded secret. But just to verify your assumption, I converted the multi-line secret to single-line. And you're right, that resolved the issue.

dmvict commented 11 months ago

@dominicmh I did not mean to commit real secret. I said 'try a hardcoded value to check behavior'.

It's good that the problem is solved.