Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
53 changes: 0 additions & 53 deletions .github/workflows/deployer.yaml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Docker Image CI

on:
release:
types: [created]
workflow_dispatch:
inputs:
component:
description: 'Component name (e.g., releaser, mongodump)'
required: true
version:
description: 'Version number (e.g., 0.1.0)'
required: true
pull_request:
branches: [ main ]
paths:
- '**/Dockerfile'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Extract component and semantic version
id: extract_info
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG=${GITHUB_REF#refs/tags/}
COMPONENT=$(echo $TAG | cut -d'-' -f1)
SEMANTIC=$(echo $TAG | cut -d'-' -f2-)
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
COMPONENT="${{ github.event.inputs.component }}"
SEMANTIC="${{ github.event.inputs.version }}"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
COMPONENT=$(echo "${{ github.event.pull_request.title }}" | grep -oP '^\w+' || echo "test")
SEMANTIC="pr-${{ github.event.pull_request.number }}"
fi
echo "::set-output name=COMPONENT::$COMPONENT"
echo "::set-output name=SEMANTIC::$SEMANTIC"
echo "::set-output name=WORKFLOW_NAME::$COMPONENT Docker Image CI"

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Check if Dockerfile exists
id: dockerfile_check
run: |
if [ -f "${{ steps.extract_info.outputs.COMPONENT }}/Dockerfile" ]; then
echo "::set-output name=EXISTS::true"
else
echo "::set-output name=EXISTS::false"
echo "No Dockerfile found for component ${{ steps.extract_info.outputs.COMPONENT }}"
exit 1
fi

- name: Build and push Docker image
if: steps.dockerfile_check.outputs.EXISTS == 'true'
uses: docker/build-push-action@v2
with:
context: ./${{ steps.extract_info.outputs.COMPONENT }}
file: ./${{ steps.extract_info.outputs.COMPONENT }}/Dockerfile
push: ${{ github.event_name == 'release' }}
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ steps.extract_info.outputs.COMPONENT }}:${{ steps.extract_info.outputs.SEMANTIC }}
${{ secrets.DOCKER_USERNAME }}/${{ steps.extract_info.outputs.COMPONENT }}:latest

- name: Echo Workflow Name
run: |
echo "Current workflow name: ${{ steps.extract_info.outputs.WORKFLOW_NAME }}"
2 changes: 2 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM ubuntu
RUN echo "test"