0

In a GitHub action, I'd like to remove the old bundle files from the FTP server after deploying the new bundle. To achieve this, I thought to

  1. Deploy new bundle
  2. Parse the hashes of (main-\*.js, polyfills-\*.js etc)
  3. Remove all matching files except the ones with the new hash

For (3), I intended using lftp with mrm main-*.!(328276e83108ad3616fd).js. Yet, this does not seem to match the expected pattern by lftp. Shopts exglob is activated in the parent shell, yet I fear this has no impact on lftp.

Any hints on how to achieve above goal are highly appreciated. Thanks!

astriffe
  • 172
  • 14

1 Answers1

1

You need to enable extended globbing for it work https://www.linuxjournal.com/content/bash-extended-globbing

The problem is that this github action doesn't enable it in the alpine docker file so you will need to write your own to do as such

The easiest way to figure this out for you is to fork the repo and create a PR to support it into the StephanThierry/ftp-delete-action repo, and in the mean time use the forked repo in your pipeline

Once you fork repo then edit this file https://github.com/StephanThierry/ftp-delete-action/blob/master/Dockerfile

  RUN apk --no-cache add lftp bash # adds bash to support shopt extglob

  RUN: shopt -s extglob # enables extended globbing

Then create a new version of the branch after you merge that into your fork and use that new branch as the action in your workflow

Edward Romero
  • 2,905
  • 1
  • 5
  • 17
  • Thanks a lot for your great answer. Will try it out asap! – astriffe Sep 01 '20 at 12:14
  • Unfortunately, that doesn't work - not even when executed on my local machine with extglob enabled. Seems as if lftp runs its own environment..? ```$> mrm main.*!(yadayada).txt \n Usage: rm [-r] [-f] files... ``` – astriffe Sep 01 '20 at 14:16