Skip to content

Commit 3186f2c

Browse files
committed
chore(ci): more tests and docker image build and publish
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 96e5098 commit 3186f2c

File tree

4 files changed

+208
-0
lines changed

4 files changed

+208
-0
lines changed

.github/workflows/ci-docker.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Docker CI
2+
3+
on:
4+
pull_request:
5+
branches: ['main']
6+
paths: ['Dockerfile','cmd/**','docs/**','internal/**','go.*','.github/workflows/ci-docker.yml']
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: '${{ github.repository }}'
11+
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: qemu
18+
uses: docker/setup-qemu-action@v2
19+
- uses: docker/setup-buildx-action@v2
20+
- id: meta
21+
uses: docker/metadata-action@v4
22+
with:
23+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
24+
- name: build
25+
uses: docker/build-push-action@v3
26+
with:
27+
context: .
28+
push: false
29+
### TODO: test multiple platforms
30+
# platforms: linux/amd64,linux/arm64
31+
tags: ${{ steps.meta.outputs.tags }}
32+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "main" ]
20+
schedule:
21+
- cron: '26 0 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'go' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v3
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
52+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53+
# queries: security-extended,security-and-quality
54+
55+
56+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57+
# If this step fails, then you should remove it and run the build manually (see below)
58+
- name: Autobuild
59+
uses: github/codeql-action/autobuild@v2
60+
61+
# ℹ️ Command-line programs to run using the OS shell.
62+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63+
64+
# If the Autobuild fails above, remove it and uncomment the following three lines.
65+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66+
67+
# - run: |
68+
# echo "Run, Build Application using script"
69+
# ./location_of_script_within_repo/buildscript.sh
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v2
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The below is pulled from upstream and slightly modified
2+
# https://github.com/webiny/action-conventional-commits/blob/master/README.md#usage
3+
4+
name: Conventional Commits
5+
6+
on:
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
name: Conventional Commits
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- uses: webiny/[email protected]
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: publish-docker-images
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
tags: ['v*.*.*']
7+
8+
concurrency: ${{ github.ref }}
9+
10+
env:
11+
IMAGE_NAME: blinklabs/tx-submit-api-mirror
12+
13+
jobs:
14+
build-and-push-image:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: qemu
22+
uses: docker/setup-qemu-action@v2
23+
- uses: docker/setup-buildx-action@v2
24+
- name: Login to Docker Hub
25+
uses: docker/login-action@v2
26+
with:
27+
username: blinklabs
28+
password: ${{ secrets.DOCKER_PASSWORD }} # uses token
29+
- name: Login to GHCR
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- id: meta
36+
uses: docker/metadata-action@v4
37+
with:
38+
images: |
39+
${{ env.IMAGE_NAME }}
40+
ghcr.io/${{ github.repository }}
41+
tags: |
42+
# Only version, no revision
43+
type=match,pattern=v(.*)-(.*),group=1
44+
# branch
45+
type=ref,event=branch
46+
# semver
47+
type=semver,pattern={{version}}
48+
- name: push
49+
uses: docker/build-push-action@v3
50+
with:
51+
context: .
52+
push: true
53+
platforms: linux/amd64,linux/arm64
54+
tags: ${{ steps.meta.outputs.tags }}
55+
labels: ${{ steps.meta.outputs.labels }}
56+
# Update Docker Hub from README
57+
- name: Docker Hub Description
58+
uses: peter-evans/dockerhub-description@v3
59+
with:
60+
username: blinklabs
61+
password: ${{ secrets.DOCKER_PASSWORD }}
62+
repository: ${{ env.IMAGE_NAME }}
63+
readme-filepath: ./README.md
64+
short-description: "A Cardano Submit API mirror service"
65+
66+
github-release:
67+
runs-on: ubuntu-latest
68+
needs: [build-and-push-image]
69+
steps:
70+
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
71+
- uses: actions/github-script@v5
72+
if: startsWith(github.ref, 'refs/tags/')
73+
with:
74+
github-token: ${{ secrets.GITHUB_TOKEN }}
75+
script: |
76+
try {
77+
await github.rest.repos.createRelease({
78+
draft: false,
79+
generate_release_notes: true,
80+
name: process.env.RELEASE_TAG,
81+
owner: context.repo.owner,
82+
prerelease: false,
83+
repo: context.repo.repo,
84+
tag_name: process.env.RELEASE_TAG,
85+
});
86+
} catch (error) {
87+
core.setFailed(error.message);
88+
}

0 commit comments

Comments
 (0)