ci: fixed most of docker image build (#6)

ci: add docker build to release and publish
This commit is contained in:
Kristoffer
2023-08-02 23:11:56 +02:00
committed by GitHub
parent bd902e99fe
commit beb9301f76
5 changed files with 1520 additions and 49 deletions

View File

@@ -1,47 +0,0 @@
name: Create and publish a Docker image
on:
release:
types:
- published
- prereleased
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@@ -9,6 +9,10 @@ on:
permissions:
contents: read # for checkout
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
@@ -19,29 +23,74 @@ jobs:
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: pnpm install
- run: pnpm lint
name: linting
- run: pnpm test
name: testing
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: pnpm audit signatures
- name: Build package
run: pnpm build
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{sha}}
type=raw,value={{branch}}-latest
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SRCIMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }}
DSTIMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: npx semantic-release

2
.gitignore vendored
View File

@@ -10,7 +10,7 @@ uploads/
.env
# Redis files
./*.rdb
*.rdb
# Code editor files
.vscode

View File

@@ -18,7 +18,29 @@
"name": "beta",
"prerelease": true
}
]
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/github",
{
"assets": [
"dist/**"
]
}
],
[
"@semantic-release/exec",
{
"tagImage": "docker tag ${SRCIMAGE} ${DSTIMAGE}:${nextRelease.version}",
"publishImage": "docker push ${DSTIMAGE}:${nextRelease.version}"
}
]
],
"preset": "angular"
},
"publishConfig": {
"access": "public"
@@ -69,6 +91,11 @@
"@directus/types": "^10.1.3",
"@directus/utils": "^10.0.8",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/github": "^9.0.4",
"@semantic-release/npm": "^10.0.4",
"@types/chai": "^4.3.5",
"@types/chai-as-promised": "^7.1.5",
"@types/config": "^3.3.0",
@@ -96,6 +123,7 @@
"knex": "^2.5.1",
"lodash-es": "^4.17.21",
"nyc": "^15.1.0",
"semantic-release": "^21.0.7",
"sqlite3": "^5.1.6",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",

1441
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff