Skip to content

Commit

Permalink
chore(ci): Switch to github workflows (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
znerol committed Dec 6, 2023
1 parent 0571e15 commit f66c220
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 85 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Build and push container image

# yamllint disable-line rule:truthy
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
container-image:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/arm64,linux/amd64
tags: "${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}-gh-build-${{ github.run_id }}"
build-args: |
build_log_label=GH Build #${{ github.run_number }}
build_log_url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
42 changes: 42 additions & 0 deletions .github/workflows/dockerhub-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Tag latest container image

# yamllint disable-line rule:truthy
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
latest-image:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract Version (Patch)
run: echo "VERSION_PATCH=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV

- name: Extract Version (Minor)
run: echo "VERSION_MINOR=${VERSION_PATCH%.*}" >> $GITHUB_ENV

- name: Extract Version (Major)
run: echo "VERSION_MAJOR=${VERSION_MINOR%.*}" >> $GITHUB_ENV

- name: Tag docker image
run: >-
docker buildx imagetools create ${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}-gh-build-${{ github.run_id }}
--tag ${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}-${{ env.VERSION_PATCH}}
--tag ${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}-${{ env.VERSION_MINOR}}
--tag ${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}-${{ env.VERSION_MAJOR}}
--tag ${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}
28 changes: 28 additions & 0 deletions .github/workflows/dockerhub-rolling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Tag rolling container image

# yamllint disable-line rule:truthy
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
rolling-image:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Tag docker image
run: docker buildx imagetools create ${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}-gh-build-${{ github.run_id }} --tag ${{ vars.IMAGE_NAME }}:${{ vars.IMAGE_VARIANT }}-rolling
34 changes: 34 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Create github release

# yamllint disable-line rule:truthy
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
release-notes:
runs-on: ubuntu-latest

permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
42 changes: 42 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Run integration test on container image

# yamllint disable-line rule:truthy
on:
workflow_call:
secrets:
PRIVATE_SSH_KEY:
required: true
PRIVATE_DIGITALOCEAN_TOKEN:
required: true
PRIVATE_CERTBOT_ACCOUNT_KEY:
required: true

env:
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
IMAGE_VARIANT: ${{ vars.IMAGE_VARIANT }}
IMAGE_BUILD_ID: "${{ vars.IMAGE_VARIANT }}-gh-build-${{ github.run_id }}"
PRIVATE_SSH_KEY: "${{ secrets.PRIVATE_SSH_KEY }}"
PRIVATE_DIGITALOCEAN_TOKEN: "${{ secrets.PRIVATE_DIGITALOCEAN_TOKEN }}"
PRIVATE_CERTBOT_ACCOUNT_KEY: "${{ secrets.PRIVATE_CERTBOT_ACCOUNT_KEY }}"
DOCKER_COMPOSE_ARGS: >-
-f integration-test/docker-compose.yml
-f integration-test/docker-compose.github.yml
-f integration-test/docker-compose.test-${{ vars.IMAGE_VARIANT }}.github.yml
jobs:
integration-test:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up integration test
run: docker-compose ${{ env.DOCKER_COMPOSE_ARGS }} build

- name: Run integration test
run: docker-compose ${{ env.DOCKER_COMPOSE_ARGS }} run sut
16 changes: 16 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Integration Tests (Pull Request)

# yamllint disable-line rule:truthy
on:
pull_request:

jobs:
build:
uses: ./.github/workflows/container-image.yml
secrets: inherit

run:
needs: build
uses: ./.github/workflows/integration-test.yml
secrets: inherit
23 changes: 23 additions & 0 deletions .github/workflows/on-push-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Publish Rolling Image (Push develop)

# yamllint disable-line rule:truthy
on:
push:
branches:
- develop

jobs:
build:
uses: ./.github/workflows/container-image.yml
secrets: inherit

run:
needs: build
uses: ./.github/workflows/integration-test.yml
secrets: inherit

tag:
needs: run
uses: ./.github/workflows/dockerhub-rolling.yml
secrets: inherit
23 changes: 23 additions & 0 deletions .github/workflows/on-push-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Publish Latest Image (Push latest)

# yamllint disable-line rule:truthy
on:
push:
branches:
- latest

jobs:
build:
uses: ./.github/workflows/container-image.yml
secrets: inherit

run:
needs: build
uses: ./.github/workflows/integration-test.yml
secrets: inherit

release:
needs: run
uses: ./.github/workflows/github-release.yml
secrets: inherit
22 changes: 22 additions & 0 deletions .github/workflows/on-release-published.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Publish Latest Image (Release Published)

# yamllint disable-line rule:truthy
on:
release:
types: [published]

jobs:
build:
uses: ./.github/workflows/container-image.yml
secrets: inherit

run:
needs: build
uses: ./.github/workflows/integration-test.yml
secrets: inherit

tag:
needs: run
uses: ./.github/workflows/dockerhub-latest.yml
secrets: inherit
84 changes: 0 additions & 84 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Official Certhub/Certbot Docker Image
=====================================

[![Build Status](https://travis-ci.org/certhub/certhub-certbot-docker.svg?branch=develop)](https://travis-ci.org/certhub/certhub-certbot-docker)
[![Build Status](https://github.com/certhub/certhub-certbot-docker/actions/workflows/on-push-latest.yml/badge.svg?branch=latest)](https://github.com/certhub/certhub-certbot-docker/actions/workflows/on-push-latest.yml)


.oO'Oo. .oO'Oo.
Expand Down
Loading

0 comments on commit f66c220

Please sign in to comment.