forked from kamba4/sunders
		
	
		
			
				
	
	
		
			58 lines
		
	
	
		
			No EOL
		
	
	
		
			1.9 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			No EOL
		
	
	
		
			1.9 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: Build (and tag) Images
 | 
						|
 | 
						|
on:
 | 
						|
  push:
 | 
						|
    branches:
 | 
						|
    workflow_dispatch:
 | 
						|
 | 
						|
jobs:
 | 
						|
  build:
 | 
						|
    runs-on: ubuntu-latest
 | 
						|
    steps:
 | 
						|
      - name: Checkout repository
 | 
						|
        uses: actions/checkout@v4
 | 
						|
 | 
						|
      - name: Set up Docker Buildx
 | 
						|
        uses: docker/setup-buildx-action@v3
 | 
						|
 | 
						|
      - name: Login to Container Registry
 | 
						|
        uses: docker/login-action@v3
 | 
						|
        with:
 | 
						|
          registry: git.hamburg.ccc.de
 | 
						|
          username: ${{ secrets.REGISTRY_USERNAME }}
 | 
						|
          password: ${{ secrets.REGISTRY_TOKEN }}
 | 
						|
      
 | 
						|
      - name: Set image tags
 | 
						|
        id: vars
 | 
						|
        run: |
 | 
						|
          if [ "${{ github.ref_name }}" = "main" ] && [ "${{ github.event_name }}" = "push" ]; then
 | 
						|
            echo "tag=latest" >> $GITHUB_OUTPUT
 | 
						|
          else
 | 
						|
            # renovate creates sub branches with `/`; these break the tagging in the build process
 | 
						|
            echo tag=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9._-]/_/g') >> $GITHUB_OUTPUT
 | 
						|
          fi
 | 
						|
 | 
						|
      - name: Build web image
 | 
						|
        run: |
 | 
						|
          docker build -f ./Containerfile -t git.hamburg.ccc.de/ccchh/sunders/web:${{ steps.vars.outputs.tag }} .
 | 
						|
        working-directory: ./web
 | 
						|
 | 
						|
      - name: Build data_handler image
 | 
						|
        run: |
 | 
						|
          docker build -f ./Containerfile -t git.hamburg.ccc.de/ccchh/sunders/data_handler:${{ steps.vars.outputs.tag }} .
 | 
						|
        working-directory: ./data_handler
 | 
						|
 | 
						|
      - name: Push images to Container Registry
 | 
						|
        run: |
 | 
						|
          docker push git.hamburg.ccc.de/ccchh/sunders/web:${{ steps.vars.outputs.tag }}
 | 
						|
          docker push git.hamburg.ccc.de/ccchh/sunders/data_handler:${{ steps.vars.outputs.tag }}
 | 
						|
        if: github.event_name == 'push'
 | 
						|
 | 
						|
      - name: Update docker-compose.yml image tags
 | 
						|
        run: |
 | 
						|
          sed -i "s/:latest/:${{ steps.vars.outputs.tag }}/g" docker-compose.yml
 | 
						|
 | 
						|
      - name: Start Docker Compose services
 | 
						|
        run: |
 | 
						|
          docker compose up -d --wait
 | 
						|
          docker compose down  |