Skip to content

Fixing missing galleries; Fixing missing commercial images; Removing … #21

Fixing missing galleries; Fixing missing commercial images; Removing …

Fixing missing galleries; Fixing missing commercial images; Removing … #21

## When we push to develop we'll build the containers and push to github container registry
name: Build and Deploy
on:
push:
branches: [ develop ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
php:
name: Build PHP Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/php
tags: |
type=ref,event=branch
type=sha
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: imagick
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: .docker/php/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}/php
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
sql:
name: Build SQL Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/sql
tags: |
type=ref,event=branch
type=sha
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: .docker/sql/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}/sql
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
deploy:
name: Deploy
needs: [ php, sql ]
runs-on: ubuntu-latest
steps:
- name: Setup SSH Key
run: |
mkdir ~/.ssh/
echo "${{ secrets.PRODUCTION_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Pull and Deploy Latest
run: |
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${{ secrets.PRODUCTION_USERNAME }}@${{ secrets.PRODUCTION }} -p ${{ secrets.PRODUCTION_PORT }} 'cd ${{ secrets.PRODUCTION_PATH }}; docker-compose -f docker-compose-prod.yml stop'
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${{ secrets.PRODUCTION_USERNAME }}@${{ secrets.PRODUCTION }} -p ${{ secrets.PRODUCTION_PORT }} 'cd ${{ secrets.PRODUCTION_PATH }}; docker-compose -f docker-compose-prod.yml rm -f'
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${{ secrets.PRODUCTION_USERNAME }}@${{ secrets.PRODUCTION }} -p ${{ secrets.PRODUCTION_PORT }} 'cd ${{ secrets.PRODUCTION_PATH }}; docker-compose -f docker-compose-prod.yml pull'
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${{ secrets.PRODUCTION_USERNAME }}@${{ secrets.PRODUCTION }} -p ${{ secrets.PRODUCTION_PORT }} 'cd ${{ secrets.PRODUCTION_PATH }}; docker-compose -f docker-compose-prod.yml up -d'