Update site certificate #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: Update site certificate | |
# Controls when the workflow will run | |
on: | |
schedule: | |
# Runs At 03:29 on day-of-month 12. | |
# https://crontab.guru/#29_3_12_*_* | |
- cron: '29 3 12 * *' | |
# Or manually trigger this | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
certbot: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: Install IBM Cloud CLI | |
run: | | |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh | |
ibmcloud plugin install -f code-engine | |
ibmcloud -v | |
- name: Login to IBM Cloud | |
env: | |
IBMCLOUD_API_KEY: ${{ secrets.BLUE_IBM_CLOUD_API_KEY }} | |
IBM_CLOUD_GROUP: ${{ secrets.BLUE_RESOURCE_GROUP }} | |
run: | | |
ibmcloud login -g ${IBM_CLOUD_GROUP} -r us-south | |
ibmcloud ce project select --name fivefifthsvoter | |
- name: Prepare CloudFlare & certbot | |
env: | |
CERTBOT_API_TOKEN: ${{ secrets.CERTBOT_API_TOKEN }} | |
run: | | |
echo "dns_cloudflare_api_token = ${CERTBOT_API_TOKEN}">cloudflare.ini | |
mkdir -p certbot-config/live/fivefifthsvoter.com | |
mkdir -p certbot-config/archive/fivefifthsvoter.com | |
mkdir -p certbot-config/accounts | |
id | |
- name: Create certificate with CloudFlare hook | |
uses: docker://certbot/dns-cloudflare | |
with: | |
args: >- | |
certonly | |
--non-interactive | |
--config-dir /github/workspace/certbot-config | |
--work-dir /github/workspace/certbot-work | |
--logs-dir /github/workspace/certbot-logs | |
--agree-tos | |
-m ${{ secrets.CERTBOT_EMAIL_ADDRESS }} | |
--dns-cloudflare | |
--dns-cloudflare-credentials=/github/workspace/cloudflare.ini | |
--domain "*.fivefifthsvoter.com" | |
- name: Fix file permissions | |
uses: docker://certbot/dns-cloudflare | |
with: | |
entrypoint: /bin/sh | |
args: -c "chmod -R o+rw /github/workspace/certbot-config" | |
- name: debug | |
run: | | |
find certbot-config/live -ls | |
find certbot-config/archive -ls | |
- name: Install certificate | |
run: >- | |
ibmcloud ce secret update | |
--name www.fivefifthsvoter.com-tls-1668394118316 | |
--cert-chain-file certbot-config/archive/fivefifthsvoter.com/fullchain1.pem | |
--private-key-file certbot-config/archive/fivefifthsvoter.com/privkey1.pem | |
- name: Shred certificates | |
run: shred -u certbot-config/archive/fivefifthsvoter.com/*.pem |