Skip to content

Commit

Permalink
update dev-deploy action
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-ebp committed Mar 27, 2024
1 parent bca1fd2 commit 98453c0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 139 deletions.
5 changes: 4 additions & 1 deletion .github/actions/create-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
TAG:
description: 'The tag of the image'
required: true
LATEST:
description: 'The latest tag of the image'
required: true
DOCKERFILE:
description: 'The path to the Dockerfile'
required: true
Expand Down Expand Up @@ -39,7 +42,7 @@ runs:
org.opencontainers.image.version=${{ inputs.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
flavor: |
latest=false
latest=${{ inputs.LATEST }}
tags: |
type=${{ inputs.TAG }}
type=semver,pattern={{version}},value=${{ inputs.VERSION }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_IMAGE_NAME: ghcr.io/geoadmin/swissgeol-assets

jobs:
Expand All @@ -30,6 +28,7 @@ jobs:
IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-app
VERSION: ${{ env.VERSION }}
TAG: edge
LATEST: false
DOCKERFILE: ./apps/client-asset-sg/docker/Dockerfile
TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -39,5 +38,6 @@ jobs:
IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-api
VERSION: ${{ env.VERSION }}
TAG: edge
LATEST: false
DOCKERFILE: ./apps/server-asset-sg/docker/Dockerfile
TOKEN: ${{ secrets.GITHUB_TOKEN }}
93 changes: 22 additions & 71 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,90 +4,41 @@ on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_IMAGE_NAME: ghcr.io/geoadmin/swissgeol-assets

jobs:
create-pre-release:
build-push-docker-images:
runs-on: ubuntu-latest
name: Build and push Docker image and create a new GitHub pre-release
name: Build and push docker images

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

- name: Set environment variables
- name: Define version
run: |
echo VERSION=$(cat VERSION).$GITHUB_RUN_NUMBER >> $GITHUB_ENV
echo COMMITED_AT=$(git show -s --format=%cI `git rev-parse HEAD`) >> $GITHUB_ENV
echo REVISION=$(git rev-parse --short HEAD) >> $GITHUB_ENV
echo VERSION=$(cat VERSION).$GITHUB_RUN_NUMBER >> $GITHUB_ENV
- name: Collect Docker image metadata (app)
id: meta-app
uses: docker/metadata-action@v5
- name: Build and push docker image (app)
uses: ./.github/actions/create-image
with:
images: ${{ env.BASE_IMAGE_NAME }}-app
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=${{ env.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
flavor: |
latest=false
tags: |
type=rc
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata (api)
id: meta-api
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-api
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=${{ env.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
flavor: |
latest=false
tags: |
type=rc
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Log in to the GitHub container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image (app)
uses: docker/build-push-action@v5
with:
context: ./
file: ./apps/client-asset-sg/docker/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-app.outputs.tags }}
labels: ${{ steps.meta-app.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-app:rc
cache-to: type=inline

- name: Build and push Docker image (api)
uses: docker/build-push-action@v5
IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-app
VERSION: ${{ env.VERSION }}
TAG: rc
LATEST: false
DOCKERFILE: ./apps/client-asset-sg/docker/Dockerfile
TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image (api)
uses: ./.github/actions/create-image
with:
context: ./
file: ./apps/server-asset-sg/docker/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-api.outputs.tags }}
labels: ${{ steps.meta-api.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-api:rc
cache-to: type=inline

IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-api
VERSION: ${{ env.VERSION }}
TAG: rc
LATEST: false
DOCKERFILE: ./apps/server-asset-sg/docker/Dockerfile
TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create pre-elease
id: create_release
uses: actions/create-release@v1
Expand Down
83 changes: 18 additions & 65 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ on:
required: true

env:
REGISTRY: ghcr.io
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_IMAGE_NAME: ghcr.io/geoadmin/swissgeol-assets

jobs:
Expand All @@ -25,71 +23,26 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set environment variables
run: |
echo VERSION=${TAG_NAME#v} >> $GITHUB_ENV
echo COMMITED_AT=$(git show -s --format=%cI `git rev-parse HEAD`) >> $GITHUB_ENV
echo REVISION=$(git rev-parse --short HEAD) >> $GITHUB_ENV
- name: Collect Docker image metadata (app)
id: meta-app
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE_NAME }}-app
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=${{ env.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
tags: |
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata (api)
id: meta-api
uses: docker/metadata-action@v5
- name: Build and push docker image (app)
uses: ./.github/actions/create-image
with:
images: ${{ env.BASE_IMAGE_NAME }}-api
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=${{ env.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
tags: |
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Log in to the GitHub container registry
uses: docker/login-action@v3
IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-app
VERSION: ${{ env.TAG_NAME }}
TAG: latest
LATEST: true
DOCKERFILE: ./apps/client-asset-sg/docker/Dockerfile
TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image (api)
uses: ./.github/actions/create-image
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image (app)
uses: docker/build-push-action@v5
with:
context: ./
file: ./apps/client-asset-sg/docker/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-app.outputs.tags }}
labels: ${{ steps.meta-app.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-app:edge
cache-to: type=inline

- name: Build and push Docker image (api)
uses: docker/build-push-action@v5
with:
context: ./
file: ./apps/server-asset-sg/docker/Dockerfile
push: true
build-args: |
VERSION=${{ env.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-api.outputs.tags }}
labels: ${{ steps.meta-api.outputs.labels }}
cache-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-api:edge
cache-to: type=inline

IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-api
VERSION: ${{ env.TAG_NAME }}
TAG: latest
LATEST: true
DOCKERFILE: ./apps/server-asset-sg/docker/Dockerfile
TOKEN: ${{ secrets.GITHUB_TOKEN }}

patch-changelog:
runs-on: ubuntu-latest
name: Patch CHANGELOG.md and update GitHub release notes
Expand Down

0 comments on commit 98453c0

Please sign in to comment.