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 0e0922d commit 4908b5b
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 11 deletions.
61 changes: 61 additions & 0 deletions .github/actions/create-image/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: 'create docker image'
description: 'Builds a docker image and tags it'
inputs:
- name: 'IMAGE_NAME'
description: 'The image name'
required: true
- name: 'VERSION'
description: 'The version of the image'
required: true
- name: 'TAG'
description: 'The tag of the image'
required: true
- name: 'DOCKERFILE'
description: 'The path to the Dockerfile'
required: true
runs:
using: 'composite'
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set environment variables
run: |
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
id: meta-data
uses: docker/metadata-action@v5
with:
images: ${{ inputs.IMAGE_NAME }}
labels: |
org.opencontainers.image.created=${{ env.COMMITED_AT }}
org.opencontainers.image.version=${{ inputs.VERSION }}
org.opencontainers.image.maintainer=EBP Schweiz AG
flavor: |
latest=false
tags: |
type=${{ inputs.TAG }}
type=semver,pattern={{version}},value=${{ inputs.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
uses: docker/build-push-action@v5
with:
context: ./
file: ${{ inputs.DOCKERFILE }}
push: true
build-args: |
VERSION=${{ inputs.VERSION }}
REVISION=${{ env.REVISION }}
tags: ${{ steps.meta-data.outputs.tags }}
labels: ${{ steps.meta-data.outputs.labels }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ inputs.TAG }}
cache-to: type=inline
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: ci

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "CodeQL"
name: code-ql

on:
push:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: dev-deploy

on:
push:
branches:
- develop
workflow_dispatch:

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

jobs:
build-push-docker-images:
runs-on: ubuntu-latest
name: Build and push docker images

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

- name: Define version
run: |
echo VERSION=$(cat VERSION).$GITHUB_RUN_NUMBER >> $GITHUB_ENV
- name: Build and push docker image (app)
uses: ./.github/actions/create-image
with:
IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-app
VERSION: ${{ env.VERSION }}
TAG: edge
DOCKERFILE: ./apps/client-asset-sg/docker/Dockerfile

- name: Build and push docker image (api)
uses: ./.github/actions/create-image
with:
IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}-api
VERSION: ${{ env.VERSION }}
TAG: edge
DOCKERFILE: ./apps/server-asset-sg/docker/Dockerfile
13 changes: 5 additions & 8 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Pre-release
name: pre-release

on:
# push:
# branches:
# - develop
workflow_dispatch:

env:
Expand Down Expand Up @@ -38,7 +35,7 @@ jobs:
flavor: |
latest=false
tags: |
type=edge
type=rc
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Collect Docker image metadata (api)
Expand All @@ -53,7 +50,7 @@ jobs:
flavor: |
latest=false
tags: |
type=edge
type=rc
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Log in to the GitHub container registry
Expand All @@ -74,7 +71,7 @@ jobs:
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-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-app:rc
cache-to: type=inline

- name: Build and push Docker image (api)
Expand All @@ -88,7 +85,7 @@ jobs:
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-from: type=registry,ref=${{ env.BASE_IMAGE_NAME }}-api:rc
cache-to: type=inline

- name: Create pre-elease
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: release

on:
release:
Expand Down

0 comments on commit 4908b5b

Please sign in to comment.