Eleventy/11ty deployment via github actions build failure using liquid template language - jekyll

When trying to deploy an Eleventy blog via github pages, a seperate workflow is auto added named pages build and deployment.
However the issue arises with the build with jekyll process step, as my blog uses liquid templating language and syntaxes conflict. For example, a file about.html in the root directory uses _includes\about.liquid and the build process issues the following error:
Liquid Exception: Invalid syntax for include tag. File contains invalid characters or sequences: "author.liquid" Valid syntax: {% include file.ext param='value' param2='value' %} in src/about.html
The build.yml file:
name: Build Eleventy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies & build
run: |
npm ci
npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages#v3
with:
publish_dir: ./_site
github_token: ${{ secrets.GITHUB_TOKEN }}
This workflow gets a clean pass but its the other auto added one that's causing trouble.
The resources I've followed to deploy 11ty sites using Github Actions avoids the pages build and deployment auto workflow since all of them are posted before the new workflow was added by github.
My question is, am I missing anything? Any new plugins perhaps for Jekyll compatibility to deploy perhaps? Can I disable the workflow and thus follow the legacy codes to deploy?

Since you're not using Jekyll to build your site, you can disable building with Jekyll by adding an empty .nojekyll file to the root of your repository.
In your case, this file would be on the main branch and should prevent GitHub from trying to build with Jekyll.

Related

Deploy Gatsby website with github actions

I'm new with gatsby and github actions. I'm trying to publish the website on github.
Here's my publish.yml file
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- uses: actions/setup-node#v3
with:
node-version: 18
- uses: enriikke/gatsby-gh-pages-action#v2
with:
access-token: ${{ secrets.**** }}
deploy-branch: gh-pages
gatsby-args: --prefix-paths
But I have this error on github:
/usr/bin/git push -f https://***#github.com/lentsius-bark/krystof-klestil.git master:gh-pages
fatal: could not read Password for 'https://***#github.com': No such device or address
Error: The process '/usr/bin/git' failed with exit code 128
The error looks like there is some issue with the access token that git push is trying to use.
Try these methods to resolve the issue.
Make sure that the access token you're using is valid and has the appropriate permissions to push to the gh-pages branch. You can create a new personal access token in your GitHub account settings if needed.
In your workflow file, change ${{ secrets.**** }} to ${{ secrets.ACCESS_TOKEN }} (replace ACCESS_TOKEN with the name of your actual secret). This will ensure that the access token is correctly substituted in the enriikke/gatsby-gh-pages-action#v2 step.

CI/CD with GitHub and Plesk

We succesfully use the Plesk / Github integration that deploys our developers pushes from github to our plesk stage web server using the Webhooks to have Pleask get the latest version. That works splendidly. What we try to establish additionally is auto compile the SCSS source and submit the resulting css as well to our stage web server. We have added an action to the workflow but how would the compiled products end up on our stage webserver. I'm unsure if the timing is right. Will the actinos be performed before deployment?
This is the yaml:
on:
push:
branches:
- stage
jobs:
build_css:
runs-on: ubuntu-latest
steps:
- name: Checkout source Git branch
uses: actions/checkout#v2
with:
ref: stage
fetch-depth: 10
submodules: true
- name: Make destination directory for compiled CSS
run: mkdir -vp /tmp/theme/assets/
- name: Compile CSS from SCSS files
uses: gha-utilities/sass-build#v0.4.11
with:
source: assets/src/main.scss
destination: /tmp/theme/assets/
- name: Move compiled CSS to path within stage branch
run: mv /tmp/theme/assets assets/

GitHub actions not identifying environment secret tokens

I recently created two workflows that deploy a preview when a push is made to a non-release branch (incl main) and deploys a production build when pushed to the release branch. However the preview workflow is failing with the error:
Error: No existing credentials found. Please run vercel login or pass "--token"
On the line:
vercel pull --yes --environment=preview --token=
I've setup the tokens in environment secrets of the repository, and below is the workflow file:
name: Preview Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{secrets.VERCEL_TOKEN }}
on:
push:
branches-ignore:
- release
jobs:
Deploy-Preview:
runs-on: ubuntu-latest
steps:
- name: "Echo values"
run: |
echo $VERCEL_PROJECT_ID
echo $VERCEL_TOKEN
- uses: actions/checkout#v2
- name: Install Vercel CLI
run: npm install --global vercel#latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
The echo isn't logging anything, not even ***(Although this isn't any important step, it was just a way to possibly debug the issue). I've followed this article from vercel to create the workflow. I'm pretty sure that the tokens are set up correctly, again at the same time, I'm unable to pinpoint the cause of the error. How do I fix this? TIA.

How to upload artifacts to existing release?

My workflow has automatic packaging and upload steps that package build artifacts and upload them to the workflow page. I also manually create releases.
I would like to do the following:
when I push to the tag that was created with a given release,
I would like to upload the zipped artifact file to that release, so users can download
the artifact. Any tips on how to do this ?
Here is my build yaml file.
Thanks!
Turns out it's dead simple to do this:
- name: upload binaries to release
uses: softprops/action-gh-release#v1
if: ${{startsWith(github.ref, 'refs/tags/') }}
with:
files: build/FOO.zip
It seems the action (softprops/action-gh-release#v1) mentioned also creates a release. But there is a much simpelere way upload an artifact to a release without the need of introducing action. The gh cli which is by default available on a GitHub hosted runners can upload the artifact for you.
assets:
name: upload assets
runs-on: ubuntu-latest
permissions:
contents: write # release changes require contents write
steps:
- uses: actions/checkout#v3
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh release upload <release_tag> <a_file>
Checkout full release example here.

Working Directory for local github actions in subdirectory

I'm trying to keep multiple github actions in the same monorepo using subdirectories, and run them like:
workflow.yml
// [...]
jobs:
run_my_script:
runs-on: ubuntu-latest
steps:
- name: Check out current repo
uses: actions/checkout#v2
- uses: ./my_action2
with:
my_input_var: "david"
./my_action2/action.yml
// [...]
runs:
using: "composite"
steps:
# Checkout files in this repo
- name: Checkout
uses: actions/checkout#v1
- name: Run myscript
run: python myscript.py "${{ inputs.my_input_var }}" # location: ./my_action2/myscript.py
shell: bash
The problem I'm having is that my action uses a python script in it's subdirectory, but the uses: action appears to run from the GITHUB_WORKING_DIR of the workflow and not the directory of the action itself.
python: can't open file 'myscript.py': [Errno 2] No such file or directory
I've looked through most of the working-directory questions surrounding github actions, but I'm still stumped.
I've also tried adding working-directory: ./my_action2 to the job's defaults: but it looks like it's not propagating to run: commands within the uses: step.
My workaround in the meantime has been to add an input for myaction2_working_directory in the workflow, and then add working-directory: ${{ inputs.myaction2_working_directory }} to every run: command in the action. This seems inelegant and repetitive. Is there a better way to do this?
contrary to the answer by Grzegorz, you cannot just run: cd foo and then expect all following steps to have a working directory of foo. as far as i can tell, the only way to do this is with the "workaround" the OP already posted -- add an input named e.g. working-directory to your action and then add working-directory: ${{ inputs.working-directory }} to every step. see https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsworking-directory
I had similar problem and for my composite actions I just added a first step as:
run: cd ${{ inputs.working_directory }}
and then all next steps are running in it.
I couldn't find a better way and having working-directory copy pasted was also something I didn't like.