Your own hosting like a boss (4 of 5)
We are going to use the repository of this webpage and GitHub Actions.
First we need to create 3 repository secrets:
- REGISTRY_USER: the registry user
- REGISTRY_PASS: the password for registry
- PORTAINER_WEBHOOK: sample https://portainer.contabo.bdunk.com/api/webhooks/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
You can get this webhook from the button “Copy Link” (Remember you have to activate the webhook):
Create a new file for the Actions Definition like this.
name: Testing the Actions with Jekyll
on:
push:
branches: [ master ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the site in the jekyll/builder container
run: |
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
jekyll/builder:latest /bin/bash -c "chmod -R 777 /srv/jekyll && jekyll build --future"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to your own Registry
uses: docker/login-action@v1
with:
registry: registry.yourdomain.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
context: .
tags: registry.yourdomain.com/moncho/bdunk-web:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: curl
uses: wei/curl@v1
with:
args: -X POST ${{ secrets.PORTAINER_WEBHOOK }}
When the action is going to be called, in this case when we make a push to master.
on:
push:
branches: [ master ]
We generate all the necessary files and save into _site foder.
Build the site in the jekyll/builder container
Login againsts our own Registry.
registry: registry.yourdomain.com
Pushing the image. In this step is very important to write the correct context.
with:
push: true
context: .
tags: registry.yourdomain.com/moncho/bdunk-web:latest
And finally we do a call to the Portainer webhook, so it’s going to get the latest image and pull it … Awesome!. More info about this.
args: -X POST ${{ secrets.PORTAINER_WEBHOOK }}
Next post we are going to make a complete sample with a complex webpage.