...
To create a new variable, click the New repository secret button. We will need to create the following variables to the following values:
KNOWN_HOSTS
A single space is finePANTHEON_MACHINE_TOKEN
On 1Password, the Machine Token value under Pantheon Dashboard: KalaCommitBotPANTHEON_REPO
URL for the project’s pantheon repo. You can find this on the pantheon page by clicking Connection Info, then coping the url part of the Git: SSH clone URL commandPANTHEON_SITE_NAME
Machine name for the project’s pantheon site (PANTHEON_SITE_NAME.env in the site url)PANTHEON_SSH_KEY
On 1Password, under “KalaCommitBot Private SSH Key”SSH_CONFIG
Code Block Host *.drush.in StrictHostKeyChecking no
Github Build and Deploy base script
Code Block |
---|
name: Build and Deploy
on:
push:
branches:
- '*'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Check out the codebase from github.
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf
ssh://git@github.com/
# Update system packages and add dependencies.
- run: sudo apt-get update -y
- run: sudo apt-get install -y libpng-dev
# Prepare .gitignore
- run: rm .gitignore; mv .gitignore-deploy .gitignore
# Install node modules and build theme.
- run: node --version
- run: cd web/themes/custom/simplytheme && npm install && npm run build
# Commit the assembled code to git in preparation for depoyment.
- run: git config --global user.name "Kala C. Bot"
- run: git config --global user.email "kalacommitbot@kalamuna.com"
- run: find web -type d -name .git -print0|xargs -0 rm -rf
- run: git add .
- run: "git commit -m \"Built ${{ github.event.repository.name }}/${{ github.head_ref || github.ref_name }} from: ${{ github.sha }} All code changes should be committed to: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }} Any commits made directly to this Pantheon repository will be overwritten.\""
# Push the assembled code to the Pantheon repo specified in the circle project environment variables.
- run: mkdir -p ~/.ssh/
- name: Create SSH key
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/private.key
sudo chmod 600 ~/.ssh/private.key
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
shell: bash
env:
SSH_PRIVATE_KEY: ${{secrets.PANTHEON_SSH_KEY}}
SSH_KNOWN_HOSTS: ${{secrets.KNOWN_HOSTS}}
SSH_KEY_PATH: ${{ github.workspace }}/.ssh/private.key
- run: echo -e "Host *drush.in\n\tStrictHostKeyChecking no" >> ~/.ssh/config
- run: echo -e "\tIdentityFile ~/.ssh/private.key\n" >> ~/.ssh/config
- run: cat ~/.ssh/config
- run: cat ~/.ssh/known_hosts
- run: git remote add pantheon ${{ secrets.PANTHEON_REPO }}
- run: git push --force pantheon ${{ github.head_ref || github.ref_name }} |
Github action scripts
In the project’s root directory, create a folder called .github, and inside that directory create a folder called workflows. Github action scripts will be .yml files inside the .github/workflows/ directory.
...