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.
Related
I want to setup continuous deployment pipeline between Github and AWS Lambda. For this, I've added main.yml file # myrepo/.github/workflows/main.yml
This is my main.yml file
name: deploy to lambda
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
jobs:
deploy_source:
name: deploy lambda from source
runs-on: ubuntu-latest
steps:
- name: checkout source code
uses: actions/checkout#v1
- name: default deploy
uses: appleboy/lambda-action#master
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_REGION }}
function_name: my_function
source: function.py
Now when I push changes to main branch nothing happens. It shows There are no workflow runs yet. I have checked the function_name and it is same as the function in AWS Console.
Your deploy_source job has runs-on: ubuntu-latest which tells Actions to use a GitHub Hosted Runner. As per your comment, you are using GitHub Enterprise Server (GHES) which is a virtual appliance on your company's network. At present, GHES does not support using GitHub Hosted Runners (it's worth noting at the time of this writing, it is on the product roadmap for support).
If you wish to run your workflow, you will need to make use of a self-hosted hosted runner. I would recommend working with your GHES administrator to get this workflow to run as there are potentially other settings and/or steps that may need to be modified or taken for this to work.
As tj-cappelletti said in their answer, you should use your hosted runners.
And also, be sure that your pipeline is on your default branch. Otherwise, you wouldn't see it there.
You need to place workflows in .github/workflows/. Note the dot in front of the folder name .github. So for your case the final path should look like this myrepo/.github/workflows/main.yml.
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/
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
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.
I'm trying to wrap my head around GitHub actions as well as how YAML is parsed.
For obvious reasons, I'd like to make use of actions already available on the marketplace. This is what I have so far..
- name: Bump Version
on:
pull_request:
branches:
- main
jobs:
bump-patch:
runs-on: ubuntu-latest
steps:
- name: Get current package version
uses: martinbeentjes/npm-get-version-action#v1.1.0
with:
# Path to package.json file (directories only), e.g. packages/mypackage/
path: ./
- name: Bump Patch Version
uses: jessicalostinspace/bump-semantic-version-action#v1.0.1
with:
semantic-version: 1.0.0
version-type: PATCH
So a few obvious things.. I need to read the current package/bower version in order to Bump it correctly with the action. I also need to make sure the branch in the PR is the one that gets updated and commits the change to that branch. Additionally the action should only run depending on the user who opened the PR.
The question:
Is it even possible to do this with GitHub actions or would a github app/service be better suited?