Netlify CMS offline local host - netlify-cms

I would like to run the NetlifyCMS locally but in an offline environment.
I was looking here: https://www.netlifycms.org/docs/authentication-backends/ and am wondering about attributes such as "auth_type". My two main questions are:
1) I have a legitimate application_id, etc. If I enter those, but run it offline, will it work?
2) Is there an "auth_type" value that I can use to disable authentication all together.
Thank you in advance for the help!

Netlify has launched a beta feature which allows working with local repo.
Navigate to a local Git repository configured with the CMS.
Run npx netlify-cms-proxy-server from the root directory of the above repository.
Update your config.yml to connect to the server:
backend:
name: proxy
proxy_url: http://localhost:8081/api/v1
branch: master # optional, defaults to master
You can check more details here

Related

Laravel Forge: How to add multiple deploy keys to one Github repository

I have one server on my Forge account with two sites. One is a production site while the other is a staging website. For example:
domain.com
test.domain.com
Both rely on the same Github repository, the staging site should be deployed when a commit is pushed to the develop branch while production should be deployed when anything is pushed to the main branch.
What did I do:
I added the deployment hook of both sites into the secrets of the Github repository:
FORGE_DEPLOYMENT_HOOK_PRODUCTION
FORGE_DEPLOYMENT_HOOK_STAGING
Then I created a Github action for both sites which starts on push to either branch and makes a curl request to the deployment hook:
name: Deploy production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy Site
run: curl ${{ secrets.FORGE_DEPLOYMENT_HOOK_PRODUCTION }}
I added the site’s deploy key of the production site (domain.com) to the repository deploy keys. When I try to add the staging key (test.domain.com) I get the error: Key is already in use. If I check the key it is actually a different key except for the first x amount of characters. Because I can’t add the key the action only works for the production site and not the staging site. I get this error when deploying staging:
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So my question is: how can I add the second deploy key? And if this is not possible, what would be the best way to setup my Github actions to achieve the same goal? I thought this to be the easiest way.

operation timedout while publishing artifacts to gitlab using goreleser

I am using golang to create a simple CLI application. I am using GoReleaser to release this to Gitlab. I followed the steps outlined in https://goreleaser.com/quick-start/ to release changes to gitlab.
I have generated a personal access token with API scope. I am tagging the changes and pushing them before I use the goreleaser to publish artifacts.
I always get the error which says release failed after 452.34s error=github/gitlab/gitea releases: failed to publish artifacts: Get "https://PRIVATEGITLABURL/api/v4/projects/PRIVATE_GITLAB_PROJECT/releases/v1%2E0%2E3": dial tcp IP_ADDRESS:443: connect: operation timed out.
My .gorelease.yml file
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- windows
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
# .goreleaser.yml
gitlab_urls:
api: https://PRIVATE_GITLAB_REPO/api/v4/
download: https://PRIVATE_GITLAB_REPO
# set to true if you use a self-signed certificate
skip_tls_verify: false
Any Ideas? My gitlab version is GitLab Enterprise Edition 14.1.5-ee
Check first if this is because of goreleaser/goreleaser issue 1879 ("
Using goreleaser behind a http(s) proxy "), which is supported since PR 1885 and goreleaser v0.147.0:
either your GitLab server is accessible through internet, and you have not set HTTP(S)_PROXY environment variables
or your GitLab server is on your intranet, you have set HTTP(S)_PROXY, but forgot the NO_PROXY (to not use the proxy when accessing through https:// an intranet resource).
Batuhan Apaydın suggests in the OP's discussion to apply the gitlab configuration:
# .goreleaser.yml
release:
# Default is extracted from the origin remote URL or empty if its private hosted.
# You can also use Gitlab's internal project id by setting it in the name
# field and leaving the owner field empty.
gitlab:
owner: user
name: repo.
The OP GrailsTest confirms, from GH discussion, in the comments:
I could not push my release as I can only access GitLab via SSH.
HTTP does not seem to work. Https has never worked on my machine, possibly because I have not set environment variables.
I could get this working on my colleagues machine who can access GitLab via HHTPS and SSH.

Is there any way to roll two paginated blogs into one Jekyll site, hosted in a single GitHub Pages repo?

I have a Jekyll site that uses the jekyll-paginate plugin and is hosted by GitHub Pages, pretty standard.
Does anybody know of other solutions to handle pagination such that I could build two blogs from the same site at domain/blog1 and domain/blog2 using this solution, but also retain pagination?
Retaining the current pagination design is not a priority. Creative ideas that require redesign are welcome.
I know jekyll-paginate-multiple exists, but GitHub Pages does not support it natively, and I would have to maintain two repos to maintain the site code and build artifacts separately, which is not ideal.
Use any custom Plugin/Gem with your GitHub Pages hosted Jekyll blog
Here is how you CAN use any custom plugin on a GitHub Pages hosted website. I use this on my own blog so I'm 100% certain that it works. The basic idea is that you use TravisCI to build your custom Jekyll site on a staging branch and then push it automatically to your GitHubPages master branch that serves your website. Here comes the quick walkthrough:
a) you configure GitHub Pages to host from the docs folder of your master branch
b) you add and configure a staging branch to be the default branch of your repo, there is where you do all your local work, releases work through setting a git tag on this branch
c) you use _config.yml file to set your destination directory to docs
# _config.yml
destination: docs
d) to avoid build issues with Travis CI you can add Gemfile.lock to your .gitignore file and the docs folder to your local .git/info/exclude since you don't want to push them anymore. To exclude the docs folder from a local push is optional, but for me that works best. You also may need to delete the Gemfile.lock first and then let Travis CI pick the fitting versions for the selected Docker OS, otherwise you can run into version conflicts which can be pretty hard to fix.
e) to deploy with Travis CI into production a.k.a. your live site you add a .travis.yml file alike :
language: ruby
rvm:
- 2.6.3
install:
- bundle install
script:
- JEKYLL_ENV="production" bundle exec jekyll build
deploy:
provider: script
script: bash script/deploy.sh
skip_cleanup: true
on:
tags: true
branch: staging
branches:
only:
- staging
- /\d+\.\d+(\.\d+)?(-\S*)?$/
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- secure: TRAVIS_SECRET_KEY_FOR_GITHUB_CREDENTIALS
sudo: false
cache: bundler
notifications:
email: false
g) script/deploy.sh looks somewhat like this:
#!/usr/bin/env bash
bundle install
JEKYLL_ENV="production" bundle exec jekyll build
git status
git add .
git commit -m"[skip travis] Automated build"
git remote set-url origin https://USERNAME:$PSW#github.com/YOUR_GIT_USER/YOUR_REPO.git
git push origin HEAD:master --force
e) to get your encrypted TRAVIS_SECRET_KEY_FOR_GITHUB_CREDENTIALS in .travis.yml with the used $PSW variable used in the deploy script, just follow the Encryption Key Doc
Once this configuration is done, you can use any Gem the same way as on localhost since the building part is not done by GitHub anymore but TravisCI.
Conclusion
You just work on staging and only let Travis CI push to your master branch. You use tags in the form 1.0.0 to deploy. All you need to do now is to add jekyll-paginate-multiple to your Gemfile and _config.yml and you are ready.
If anyone is interested in more details for those step, have a look at this Blog Post detailing the issue
If jekyll-paginate-multiple works in your context, you can use it on GitHub pages as well.
All you need to do is to copy
https://github.com/scandio/jekyll-paginate-multiple/blob/master/lib/jekyll-paginate-multiple.rb
into your repos _plugins folder and you are good to go.

GitHub - Using multiple deploy keys on a single server

Background
I have a system where when I push changes to my Repository, A web hook sends a request to my site which runs a bash script to pull the changes and copy any updated files.
I added a second repository with its own deploy key but after doing so i was getting a permission denied error when trying to pull changes.
Question
Is there a way to use 2 deploy key's on the same server?
Environment Details
Site uses Laravel 5.6, Symfony used to run shell script
Git 1.7
Go Daddy web hosting (Basic Linux one)
Notes
Script just runs git pull command
Error given is " Permission denied (publickey) "
SHH is used as a deploy key so only read access, there is one other project also using a deploy key on the same server
Thank you in advance for you help! Any other suggestions are welcome!
Edit #1
Edited post to reflect true problem as it was different to what I though (Feel free to revert if this is bad practice), please see answer below for details and solution
What i though was an issue with authentication what actually an issue with the git service not knowing which ssh key to use as i had multiple on the server.
The solution was to use a config file in the .ssh folder and assign alias to specify which ssh key to use for git operations in separate repositories.
Solution is here: Gist with solution
This gist explains the general idea, it suggests using sub-domains however a comment further down uses alias which seems neater.
I have now resolved the issue and the system is working fine with a read-only, passphrase-less deploy key.
This can be done by customizing the GIT_SSH_COMMAND. As ssh .config only gets the host, you have to create aliases to handle different paths. Alternatively, as the git CLI sends the path of the repo to the GIT_SSH_COMMAND, you can intercept the request in a custom script, added in between git and ssh.
You can create a solution where you extract the path and add in the related identity file, if available on the server.
One approach to do this can be found here.
Usage:
cp deploy_key_file ~/.ssh/git-keys/github-practice
GIT_SSH_COMMAND=custom_keys_git_ssh git clone git#github.com:github/practice.git

Using local configs in a Heroku deployment environment

I'm trying to migrate my app to Heroku - I have a config file that varies with development/staging/production environments as it contains uniquely assigned keys (from Facebook, S3, etc.), so I keep it out of the repository and keep the configs local.
As such I'm trying to find a solution for Heroku to have that config file since Heroku deploys from the repository. I noticed Heroku deploys from the master branch - can it deploy from another branch? Because then I could commit the Heroku configs there, and have it not overwrite the other environments' configs every time it pulls.
Thanks!
I believe Heroku always launches the master branch of the Gt repo, but they support config vars to address exactly this issue.
You can use foreman and heroku-config for this.
Check out the article at heroku dev center:
http://devcenter.heroku.com/articles/config-vars
I love this because you can keep the .env file in .gitignore and shield your production variables from ending up in the repository.

Resources