Setup Github action to download a zip file - github

I have a Google Chrome and Mozilla Firefox extension in a same GitHub repository. They are separated in two branches and I am "exposing" the original URL to download the repository for each branch:
The approach to install a Firefox extension is quite long and messy since it needs to be unzipped and zipped again. So, someone recommended me using Github actions to create a release file from specific branches using this Github action: Zip Release.
According to their documentation I have tried to replicate the YAML file for my use case using the Github action creation wizard and naming that file firefox.yml that created a folder in the repository root: .github/workflows/firefox.yml:
name: Create Archive
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: my-user/the-repo#dev-firefox
- name: Create Firefox Release
uses: thedoctor0/zip-release#main
with:
type: 'zip'
filename: 'dev-firefox.zip'
path: './releases'
exclusions: '*.git* /*node_modules/* .editorconfig /*releases/*'
But after it starts it immediately fails with the following message:
Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/_actions/my-user/the-repo/dev-firefox'. Did you forget to run actions/checkout before running your local action?
I also tried adding - uses: actions/checkout#master just before the line - uses my-user/the-repo#dev-firefox but it won't work.
Not sure how to properly write the workflow YAML configuration. Any suggestions?

You're confusing uses with checking out a repository. uses indicates an action to use, with the part after the # specifying the version of the action. To check out a specific branch of your repo, you can use the checkout action with the ref parameter:
steps:
- uses: actions/checkout#v3.1.0
with:
ref: dev-firefox

Related

Unable to deploy flutter project to Github Pages

I can't host flutter web application on github pages. The workflow file looks like this:
name: Build & Deploy weathunits_configurator
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-and-deploy:
name: 'Build & Deploy web app'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: 'Install Flutter and Dart SDK'
uses: subosito/flutter-action#v2
with:
channel: stable
flutter-version: 3.3.9
cache: true
- name: 'Flutter enable Web'
run: flutter config --enable-web
- name: 'Get dependencies'
run: flutter pub get
working-directory: example/weathunits_configurator
- name: 'Build web app'
run: |
cd example/weathunits_configurator
flutter build web --web-renderer=canvaskit --base-href='/weathunits_configurator/' --release
- name: 'Deploy web app'
uses: peaceiris/actions-gh-pages#v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: example/weathunits_configurator/build/web
What I'm trying to do: my project lies in the example/weathunits_configurator folder, after building it will be in the example/weathunits_configurator/build/web folder.
The web project is placed in the gh-pages branch and looks like this link.
We open the application through the https://packruble.github.io/weather_animation/ (I'd like to see another path. Not /weather_animation/, but /weathunits_configurator/.) and see a blank screen. I see the following in the console brave:
What I tried:
Use JamesIves/github-pages-deploy-action#v4 instead of peaceiris/actions-gh-pages#v3
Use different `flutter build web' parameters
Changed the input and output folder in settings deploy action.
I think the problem is that because my project, which needs to be deployed, is in a subfolder, it cannot be built normally. Either there is a problem with the --base-href='/weathunits_configurator/' tag. Or the problem is somewhere else.
How to launch this project on Github Pages?
In the end, the problem was solved by using the --base-href='/weather_animation/' flag which specifies the repository name. It is the name of the github repository that should be specified in this flag and nothing else!
Recall that the file on the path web/index.html has the following line <base href="$FLUTTER_BASE_HREF">.
And yes, sometimes github pages are not lightning fast. You need to wait some time for the changes to take effect after your deploy.
Consider the error message:
Loading failed for the <script> with source
“https://packruble.github.io/weathunits_configurator/flutter.js”.
weather_animation:40:1
That means a base-href set to /weathunits_configurator/ cannot work because a project GitHub Page is based on the repository name.
Here, it is weather_animation, not weathunits_configurator.
The simplest option would be to rename the repository into weathunits_configurator, and remove the base-href, since a project site is hosted at http(s)://<username>.github.io/<repository>.
That seems easier than configuring a custom domain for your GitHub Pages site.
The OP Ruble confirms in the comments it is working, but keeping --base-href='/weather_animation/', using the name of the repository though.

Astro.js deployment: Media files not rendering

I've recently tried to deploy my 1st portfolio on github pages which is being built with Astro.js.
Everything looks as it should on dev mode, and the build doesn't start any errors, but when I access the page where my portfoli was deployed the images are not rendering. All the images are SVGs and I also have a video that plays on the backgroud which is in .mp4 format. For the HTML I'm using and tags for the images and the video respectively.
For deployment I followed Astro's documentation
And basicly coipied they're yaml file.
.github/workflows/main.yaml:
name: Deploy Astro to GitHub Pages
on:
# Trigger the workflow every time you push to the `main` branch
# Using a different branch name? Replace `main` with your branch’s name
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab on GitHub.
workflow_dispatch:
# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository using git
uses: actions/checkout#v2
- name: Install, build, and upload your site
uses: withastro/action#v0
with:
# path: . # The root location of your Astro project inside the repository. (optional)
# node-version: 16 # The specific version of Node that should be used to build your site. Defaults to 16. (optional)
package-manager: npm # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages#v1
For more detailed information you can find
the deployed page here
src code here
EDIT: clearly I didn't read the documents well enough as the error was solved by this warning warning
For a complete answer, and in addition to the base config that you mentioned in your question, as you're using github pages for deployment, it is important to add a .nojekyll file in your /public/ directory or ensure it is placed in your repo root or the static folder to be deployed by github
references :
base : https://docs.astro.build/en/reference/configuration-reference/#base
bypassing Jekyll on Github Pages : https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/

Add and run GitHub Actions on feature branch?

I'm currently using the "git-flow" branching model outlined here. Following that model, once I've completed work on a feature branch, I'd like to add new GitHub actions to that branch (for example, to run my feaure's automated tests) before the branch is merged.
Following the branching model, I don't want to define the actions in a workflow file on the default branch before that feature branch is merged into it. Ideally I want to add the actions on the feature branch itself before the merge, but this doesn't appear to work.
I've added the below sample workflow to my feature branch, but GitHub does not detect it. Am I missing something here, or can workflows only detected and run once they're on the default branch? If the latter is true, do people generally merge their branches, then add workflows for them?
# Name workflow
name: Test workflow
# Read only permissions
permissions: read-all
# Triggered once every 15 minutes
on:
workflow_dispatch:
schedule:
- cron: '15 * * * *'
# Listing of jobs to be run
jobs:
# Just output the Python version for now.
python-tests:
name: Python Tests
runs-on: ubuntu-latest
# Use the environment configured with secrets
environment: python-test-environment
# Set the working directory?
defaults:
run:
working-directory: tests
steps:
# Checkout the repository
- name: Checkout
uses: actions/checkout#v2
ref: 'dev-tests'
# Configure Python
- name: Set up Python 3.7
uses: actions/setup-python#v2
with:
python-version: 3.7
# Output the Python version
- name: Display version
run: python -c "import sys; print(sys.version)"
Update: I can see now that the "schedule" trigger only works on the default branch. However, removing it and just using the workflow_dispatch trigger still (on the feature branch YML file) still does not show the workflow on GitHub.

Is there a way to send a completed build from a GitHub Action to a release?

I would like to push a build that was completed on a GitHub action workflow using this code:
name: Build
on: [pull_request, push]
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout the code
uses: actions/checkout#v2
- name: Build the app
run: ./gradlew build
Currently this works for building the app and updating a status badge, but I would like the apk file from this build to be pushed directly as a pre-release. Is this possible?
Yes, it is possible.
If you want to make a GitHub release containing the file, there are a lot of GitHub actions. This action - automatic-releases, I think can do the work for you.
This action simplifies the GitHub release process by automatically uploading assets, generating changelogs, handling pre-releases, and so on.
As I see you use Gradle, you can check the GitHub docs for publishing-java-packages-with-gradle

Can I maintain a single binary on GitHub outside git's tracking?

I have a GitHub repository consisting of LaTeX code for my resume. Currently, I'm including the generated PDF file as a file in git, i.e. it's tracked in version control. The only purpose of including the PDF is to have a link to the latest resume PDF that I can send to people. Hence, I don't really need to track a binary file in version control at all.
Is there a way to get rid of tracking this binary through git? I'm thinking of generating the PDF with GitHub Actions, then uploading it somewhere. This way I don't have to include the PDF in git, while having a link to the latest build (off the master branch) that I can share. Does GitHub have a place where I can keep this PDF?
I've noticed that most GitHub release assets are available through a link like https://github.com/owner/repo/archive/file.tar.gz. Since I just want to maintain a single copy that is built with every commit, using GitHub releases would be overkill for this. Can I somehow "dump" the PDF from the latest build in https://github.com/me/resume/archive/resume.pdf? If not, is there any other way?
Your best bet is to have a single release and update that file again and again.
There's also artifacts for GitHub Actions, but they can only be downloaded by logged-in users.
Following up on #riQQ's answer, I was able to automate this using GitHub Actions. Here's a sample workflow YAML file:
name: Update binary
on:
push:
branches:
- master
jobs:
build:
name: Update binary
runs-on: ubuntu-latest
steps:
# Checkout the repo at the commit which triggered this job
- name: Set up git repo
uses: actions/checkout#v2
with:
fetch-depth: 0 # used to get the tag of the latest release
# TODO: Action for compiling and generating the binary
- name: Compile code
# Removes the latest release, so that we can create a new one in its place
- name: Delete latest release
uses: ame-yu/action-delete-latest-release#v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# (optional) Removes the tag associated with the latest release
- name: Delete release tag
run: |
git tag -d release
git push origin :release
continue-on-error: true # in case there's no existing release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Creates the new release with the binary as a release asset.
# If the previous Action was skipped, then this keeps the same tag as the
# previous release.
- name: Create new release
uses: softprops/action-gh-release#v1
with:
body: "Release notes"
name: Latest
tag_name: release
files: /path/to/binary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NOTE: This approach only works if you want to maintain a single release for the sole purpose of maintaining the binaries as release assets.
The binary will now be visible in the releases page, and its URL can be obtained.