Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

create github action that purges modified static files #465

Open
tripodsan opened this issue Sep 10, 2020 · 25 comments
Open

create github action that purges modified static files #465

tripodsan opened this issue Sep 10, 2020 · 25 comments
Assignees

Comments

@tripodsan
Copy link
Contributor

similar to https://github.com/adobe/theblog/blob/master/.github/workflows/purge-code.yaml, just a bit smarter to automatically purge the files that were pushed.

@tripodsan tripodsan self-assigned this Sep 10, 2020
@davidnuescheler
Copy link
Contributor

this possibly should be a node implementation over shell script

@tripodsan
Copy link
Contributor Author

see an example on how to react on a push event:
https://github.com/adobe-rnd/github-touch-action

@koraa koraa self-assigned this Oct 1, 2020
@koraa
Copy link

koraa commented Oct 1, 2020

Shure this should be a gh action? Seems like a bit of an odd choice…; how should this action be exposed to users? How should people enable it for their page? If enabled automatically for every repository, how should we make that happen?

Might be useful to use the format of a user story: How is the behaviour right now as a user of helix-pages? How should it change?

@trieloff
Copy link
Contributor

trieloff commented Oct 1, 2020

The Blog currently uses a project-specific GH action to purge the outer and inner CDN cache of all known static files when a push occurs. It would be easier if projects could simply refer to a pre-built action instead of each project building their own script.

This pre-built action should use the same HLXPURGE method of purging, but it should figure out which files to purge based on the pushed commits and the base URL from a config.

Building a GH action is easier than building a full-blown GH app.

@koraa
Copy link

koraa commented Oct 1, 2020

So what would be the user flow to enable this? Shouldn't it be enabled by default?

@koraa
Copy link

koraa commented Oct 1, 2020

Btw, the HLXPURGE HTTP verb, have we considered the potential impact such an http method can have on the possibility of amplified DOS attacks when unauthenticated?

@tripodsan
Copy link
Contributor Author

So what would be the user flow to enable this? Shouldn't it be enabled by default?

the user would add a purge-action.yaml to his repositorys .github/workflows directory.

@trieloff
Copy link
Contributor

trieloff commented Oct 2, 2020

Btw, the HLXPURGE HTTP verb, have we considered the potential impact such an http method can have on the possibility of amplified DOS attacks when unauthenticated?

We have, and decided to leave it open.

@koraa
Copy link

koraa commented Oct 5, 2020

How should the action determine which files to purge? It should probably for instance pure X.html for a changed X.md file. Where should these rewriting rules come from?

@koraa
Copy link

koraa commented Oct 5, 2020

https://github.com/koraa/hlx-gh-action-purge-updated-cache

Please review before elevation to adobe/ repo. Outstanding todos:

  • Add tests & ci
  • Adjust readme & package.json (clean up+adjust to correct repository name/location)

@trieloff
Copy link
Contributor

trieloff commented Oct 5, 2020

  • license
  • code of conduct
  • contributing

@trieloff
Copy link
Contributor

trieloff commented Oct 5, 2020

Where should these rewriting rules come from?

No rewriting needed, the action works as is

@tripodsan
Copy link
Contributor Author

@koraa looks good so far. what's missing is a way to filter the files that should trigger the purge. e.g. only the modified files below scripts/** should be purged.

@koraa
Copy link

koraa commented Oct 6, 2020

Wasn't a requirement in the ticket. Please specify a way to provide these filters…

@trieloff
Copy link
Contributor

trieloff commented Oct 6, 2020

The outer CDN URL should be optional, ref--repo--owner.hlx.page can be used.

@koraa
Copy link

koraa commented Oct 6, 2020

Can someone please test this in the blog to see if it actually works before I move the repo and reset the git history?

@tripodsan
Copy link
Contributor Author

tripodsan commented Oct 7, 2020

Wasn't a requirement in the ticket. Please specify a way to provide these filters…

hmm...right. I forgot to mention it. best would be using an input property:

on: push

jobs:
  ci_trigger:
    runs-on: ubuntu-latest
    name: Clear helix pages cache
    steps:
      - name: Trigger
        id: trigger
        uses: adobe-rnd/github-purge-cache-action@master
        with:
          repo-token: ${{ secrets.MY_GITHUB_TOKEN }}
          include: "scripts/**"

@tripodsan
Copy link
Contributor Author

tripodsan commented Oct 7, 2020

Can someone please test this in the blog to see if it actually works before I move the repo and reset the git history?

please move it to adobe-rnd. you can continue development there.

would be best to follow the pattern of the other actions: github-purge-cache-action

@koraa
Copy link

koraa commented Oct 7, 2020

Wasn't a requirement in the ticket. Please specify a way to provide these filters…

hmm...right. I forgot to mention it. best would be using an input property:

Precisely which grammar should this use. Looks like glob patterns, but those are not really standardized; your example looks like using the globstar bash extension. What about the ksh93 extglob extension with support for the klenee star? Are we using some standardized library for glob matching? Maybe we should enforce consistency there…

Given that this is not entirely trivial, I think it would be better to open a ticket in the repo with the full specification once it's been moved rather than hash this out as part of this ticket unless @davidnuescheler thinks this urgently needs to be added.

@koraa
Copy link

koraa commented Oct 7, 2020

Looks like I have insufficient permissions to move into adobe-rnd. Somebody else will have to go for it.

@tripodsan
Copy link
Contributor Author

tripodsan commented Oct 7, 2020

@koraa use https://www.npmjs.com/package/glob, and whatever pattern they support. that's what we use elsewhere.

IMO it is important to add this - you can also hardcode the scripts and styles directory restriction, if you don't want to add it.

@koraa
Copy link

koraa commented Oct 7, 2020

Please move that requirment into it's own ticket after the repo has been moved.

@tripodsan
Copy link
Contributor Author

@koraa you need to give me admin rights on that repository, otherwise I cannot move it.

@tripodsan
Copy link
Contributor Author

I created the issue adobe-rnd/github-purge-cache-action#2

@koraa
Copy link

koraa commented Oct 8, 2020

Right, I added @trieloff @tripodsan and @davidnuescheler any one of you should be able to move :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants