Skip to content

Commit

Permalink
Configure action for automated testing, update CI/CD (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry committed Nov 7, 2023
1 parent fe3127a commit 3bde922
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Deploy Published Image
on:
workflow_call:
workflow_run:
workflows: [Docker Build & Publish]
types:
- completed
jobs:
update-docker-image:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Update Docker Image & Restart
runs-on: self-hosted
steps:
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
name: Docker Build & Publish

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
workflow_dispatch:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
workflow_run:
workflows: [Test]
types:
- completed

env:
# Use docker.io for Docker Hub if empty
Expand All @@ -23,6 +16,7 @@ env:

jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Build & Publish
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -97,6 +91,7 @@ jobs:
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Deploy Published Image
uses: ./.github/workflows/deploy.yml
needs: build
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on:
workflow_dispatch:
push:
branches: [ "*" ]
pull_request:
branches: [ "main" ]

jobs:

test:
name: Test ccinvoice
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install wkhtmltopdf

- name: Set Environment Variables & Test
# This is specifically for generating PDFs - setting this variable means we don't have to run the server to provide the HTML
# response for wkhtmltopdf to create the PDF from. We're only testing the file is created and placed in the right directory,
# so the content doesn't really matter.
run: export BASE_URL=https://duckduckgo.com/?q= && go test -v

0 comments on commit 3bde922

Please sign in to comment.