Create a Github action that'll tar files every time I push to 'main'

Hey! New to github actions and now I have a repository called Distro_wallpapers that collects wallpapers from distros. Anyway, I have a raw folder that has tar files for the folders, now every time I push to the master branch, I clone the repository, compress the tar files, then upload them to github. Now it’ll be really great if I could make a github action that’ll tar all of those folders, then push them to /raw/[distro-name]. Then it would save me a lot of time so I could focus on other things, now I can’t make it as I don’t have much experience, so could anyone help me?

I wouldn’t recommend adding tar archives to the repository, as in track tar archives with Git, commit and push them to the repo. Git isn’t meant for versioning large binary files. Instead, consider the following options:

  • Let a workflow save the tar archives as a build artifact. GitHub keeps workflow artifacts for up to 90 days. You will be able to download the build artifact zipped up as a single file from the Actions tab. Everyone who is logged into GitHub will be able to download it, but not users who are not logged in or don’t even have a GitHub account. The downsides are that you need to locate the right workflow run to get to the download link and that it’s only available for 90 days max.

  • Let a workflow create a release and add the tar archives to it. This has the advantage that the downloads will be available without time limit and that everyone will be able to download them. The official actions/create-release action is not maintained anymore, but the following actions are:

  • If it does not necessarily have to be tar archives, then you could simply use GitHub’s feature to download the repository as zip file:

If you want to create the archives using a workflow, then you would use the following as workflow trigger:

on:
  push:
    branches:
      - master

This will trigger when you push directly to the master branch, but also when you merge pull requests into master.

1 Like