I am trying Deploy a Website using Jekyll:
Initialize Your Repo
the error msg: "Reinitialized existing Git repository in /home/ccuser/workspace/daw/.git/"?
Related
I need to do some directory grooming before my app is ready to be tested or deployed. I would like to utilize a Makefile target which calls a shell script in the repo to make this CI/CD-agnostic. One can call this target with make prepare_directory
The CI platform I am using is Github Actions. Here are the relevant parts of the workflow which is being run on new Pull Requests:
name: PR Tests
env:
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
with:
fetch-depth: 1
- name: Prep directoy
run: make prepare_directory
Here is the relevant part of the Makefile (which works exactly as expected locally):
...
prepare_directory:
./scripts/prepare_directory.sh
clean:
#rm -Rf ./$(BUILDPREFIX)
.PHONY: all clean docker lint prep_avro $(dockerbuilds)
Here is the relevant part of the ./scripts/prepare-directory.sh script:
#!/bin/bash -e
# ...
# clone repo using https and GITHUB_TOKEN
git clone https://$GIT_TOKEN#github.com:USERNAME/REPO.git
When I try to clone using that URL, from the shell script, the script fails (along with the Github workflow pipeline) with the following error: fatal: unable to access 'https://github.com:USERNAME/REPO.git/': URL using bad/illegal format or missing URL
Does anybody know what I'm doing wrong?
You can add this action after your checkout step and GitHub can access your private repo dependancy.
Note:- Make sure to add a server's private key as a secret, public key to GitHub SSH keys and Please replace your private repo URL from https+auth_token to SSH. ssh://git#github.com/your_group/your_project.git
Below is the example
- uses: webfactory/ssh-agent#v0.4.1
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
SSH_KEY is the private key secret which you created.
I've created a GitHub App and Github Action to workaround these limitations GitHub Actions Access Manager. Feel free to drop some feedback.
Workflow
This GitHub action will request an access token for a Target Repository from the App Server, authorize by the GitHub Action ID Token (JWT signed by GitHub).
The App Server requests a GitHub App Installation Token to read .github/access.yaml file in Target Repository.
The App Server reads .github/access.yaml file from Target Repository and determine which permissions should be granted to Requesting Repository, authorized by the GitHub App Installation Token from step 2..
The App Server requests a GitHub App Installation Token with granted permissions for Source Directory and send it back in response to the GitHub action from step 1..
The GitHub action sets the token as environment variable $GITHUB_ACCESS_TOKEN and as step output value ${{ steps.github-actions-access.outputs.token }}.
Further steps can then utilize this token to access resources of the Target Repository.
The URL in your prepare-directory.sh script's git clone call has a typo in it:
# clone repo using https and GITHUB_TOKEN
git clone https://$GIT_TOKEN#github.com:USERNAME/REPO.git
The URL there is halfway between an HTTPS git URL and an SSH one. The : should be a /. Assuming your $GIT_TOKEN contains just the token and nothing else, you'd also need a : before the #:
git clone https://$GIT_TOKEN:#github.com/USERNAME/REPO.git
If your $GIT_TOKEN contained the complete auth string, which for a Github App installation access token would be something like "x-access-token:ghs_..." then you wouldn't need the : following $GIT_TOKEN, you'd just have $GIT_TOKEN#github.com.
I have private repo A (which is a library) and that repo has releases. Now I have repo B which has a dependency on the artifacts of A. The dependency (i.e. which version) is stored in a json file in B. What I'm looking for is a way to download the artifacts of release X from repo A in an action/workflow in repo B.
I have seen a lengthy bash script which make this possible, but I'm wondering if there are off the shelf actions around.
If you are using a Linux runner, you can use the Fetch Github Release Asset action.
uses: dsaltares/fetch-gh-release-asset#master
with:
repo: "user/repo"
version: "tags/v1"
file: "filename.ext"
target: "targetFolder/targetFileName.ext"
token: ${{ secrets.PAT_TO_ACCESS_PRIVATE_REPO }}
Inputs
token
Required The GitHub token. Typically this will be ${{ secrets.GITHUB_TOKEN }}
file
Required The name of the file to be downloaded.
repo
The org/repo containing the release. Defaults to the current repo.
version
The release version to fetch from in the form tags/<tag_name> or <release_id>. Defaults to latest.
target
Target file path. Only supports paths to subdirectories of the GitHub Actions workspace directory
Unable to host my repo on GitHub pages even after renaming my html file to index.html. It only shows the readme file after I click on the generated link.
Inside your project directory make sure you do the following
To initiate a git repository
git init
Add your remote repostiory
git remote add origin https://github.com/username/test.git
Add all your changes
git add .
Commit changes
git commit -m "initial"
Push your commit to remote repository
git push -u origin main
After doing the following you should see all your files in your github repository
I use Gitlab pages and Jekyll to generate a website, and a python script to generate the images and data files (JSON) used by Jekyll. As I need to update these files daily, I commit and push dozens of images to update the website, which is not really convenient.
I also use Github Actions to generate and store these files as artifacts on Github:
- name: Main script
run: |
python generate_images.py --reload # saves in folder saved_images
# I manually commit and push these images in jekyll/assets/img to update the site
- name: Upload images artifacts
uses: actions/upload-artifact#v1
with:
name: saved_images
path: saved_images
I would find it better to tell Jekyll to use the artifacts, instead of the committed files, so that I can update the site by just re-launching the github action (hopefully without extra commit or branch change). Actually that's what I've seen on Gitlab on another project:
pages:
stage: Web_page
before_script:
- python generate_images.py --reload
- cp -r saved_images/*.png jekyll/assets/img
- cd jekyll
- bundle install --path vendor
script:
- bundle exec jekyll build -d ../public
...
So I wonder if it is possible to use artifacts as Jekyll assets and data files in Github pages?
this is my blog hosted in github.
http://john-qin.github.io/
now, i want to setup octopress on my ubuntu 12.04. I followed the instruction on this page.
http://octopress.org/docs/deploying/github/
I got stuck after "rake setup_github_pages". this instruction is for setting up brand new environment for octopress. I already have it in github. how do I pull the existing one? and where should I put them?
Octopress repositories have two branches, source and master. The source branch contains the files that are used to generate the blog and the master contains the blog itself.
When the local folders are initially configured according to the Octopress Setup Guide, the master branch is stored in a subfolder named _deploy. Since the folder name begins with an underscore, it is ignored when you git push origin source. Instead, the master branch (which contains your blog posts) gets updated when you rake deploy.
To recreate the local directory structure of an existing Octopress blog, follow these instructions.
First you need to clone the source branch to the local octopress folder.
git clone -b source git#github.com:username/username.github.com.git octopress
Then clone the master branch to the _deploy subfolder.
cd octopress
git clone git#github.com:username/username.github.com.git _deploy
Then run the rake installation to configure everything
gem install bundler
rbenv rehash # If you use rbenv, rehash to be able to run the bundle command
bundle install
rake setup_github_pages
It will prompt you for your repository URL. Enter the read/write url for your repository
(For example, 'git#github.com:your_username/your_username.github.com)
You now have a new local copy of your Octopress blog. Check out this post for more information.