Skip to content

Commit

Permalink
add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Nov 29, 2024
1 parent d4fdf2b commit 380a397
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/build-and-push-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build Docker Image

on:
workflow_call:
outputs:
apollon_standalone_image_tag:
description: "The tag of the apollon standalone image that was built"
value: ${{ jobs.build.outputs.apollon_standalone_image_tag }}

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./Dockerfile.redis
image: ghcr.io/ls1intum/Apollon_standalone/apollon-standalone
context: .
path: apollon-standalone
outputs:
apollon_standalone_image_tag: "${{ steps.output-tag-apollon-standalone.outputs.apollon_standalone_image_tag }}"

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Install Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
- name: Build and push Docker Image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}

- id: output-tag-apollon-standalone
run: |
if [[ "${{ matrix.path }}" == "apollon-standalone" ]] && [[ "${{ steps.changed-files.outputs.any_changed }}" == "true" ]]; then
echo "apollon_standalone_image_tag=${{ steps.meta.outputs.version }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.path }}" == "server" ]]; then
echo "apollon_standalone_image_tag=latest" >> "$GITHUB_OUTPUT"
fi
17 changes: 17 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build and Deploy to Dev

on:
pull_request:

jobs:
build-dev-container:
uses: ./.github/workflows/build-and-push-docker.yml
secrets: inherit
# deploy-dev-container:
# needs: build-dev-container
# uses: ./.github/workflows/deploy_docker.yml
# secrets: inherit
# with:
# environment: Dev
# server_image_tag: "${{ needs.build-dev-container.outputs.server_image_tag }}"
# client_image_tag: "${{ needs.build-dev-container.outputs.client_image_tag }}"

0 comments on commit 380a397

Please sign in to comment.