Skip to content

logo images

logo images #61

Workflow file for this run

name: Publish Docker image
on:
push:
branches: [main, develop, 387-strapi-cms]
paths-ignore:
- "apps/api/**"
- "apps/skde/**"
pull_request:
branches: [main, develop, dependency_updates]
paths-ignore:
- "apps/api/**"
- "apps/skde/**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
push_to_registries:
name: Build and push Strapi Docker image to docker hub
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "eu-west-1"
steps:
- name: Set release variables
if: github.ref == 'refs/heads/main'
run: |
echo "S3Key='prod-mong-strapi.json'" >> $GITHUB_ENV
echo "env_name=prod-mong-strapi" >> $GITHUB_ENV
echo "version_label=${GITHUB_SHA:0:7}_prod_${RANDOM}" >> $GITHUB_ENV
echo "descr='Release tag deploy'" >> $GITHUB_ENV
- name: Set QA variables
if: github.ref == 'refs/heads/387-strapi-cms'
run: |
echo "S3Key='qa-mong-strapi.json'" >> $GITHUB_ENV
echo "env_name=qa-mong-strapi" >> $GITHUB_ENV
echo "version_label=${GITHUB_SHA:0:7}_qa_${RANDOM}" >> $GITHUB_ENV
echo "descr='Main commits deploy'" >> $GITHUB_ENV
- name: Check out the repo
uses: actions/[email protected]
- run: yarn install
- run: yarn workspace strapi run build
- name: Lint Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: "apps/strapi/Dockerfile"
- name: Prepare
id: docker_meta
uses: docker/[email protected]
with:
images: hnskde/mong-strapi
tags: |
type=ref,event=branch
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push to Docker Hub
uses: docker/[email protected]
with:
context: ./apps/strapi
file: ./apps/strapi/Dockerfile
build-args: version=${{ env.version_label }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update elasticbeanstalk
if: github.event_name != 'pull_request'
run: |
aws elasticbeanstalk create-application-version --application-name mong-strapi --source-bundle S3Bucket="elasticbeanstalk-eu-west-1-247247832514",S3Key=${{ env.S3Key }} --version-label ${{ env.version_label }} --description ${{ env.descr }}
aws elasticbeanstalk update-environment --environment-name ${{ env.env_name }} --version-label ${{ env.version_label }}