Skip to content

Commit

Permalink
updates workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Mar 7, 2024
1 parent 15ec913 commit 1411185
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 353 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-deploy-on-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

name: Build and Deploy to Production on Release

on:
release:
types: [ released ]

jobs:
build-production:
name: Build production ${{ github.event.release.tag_name }}
uses: mlibrary/platform-engineering-workflows/.github/workflows/build-production.yml@v1
with:
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.event.release.tag_name }}
dockerfile: Dockerfile
secrets: inherit

deploy-production:
needs: build-production
name: Deploy to production
uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1
with:
image: ghcr.io/mlibrary/${{ vars.IMAGE_NAME }}:${{ github.event.release.tag_name }}
file: environments/account/production/checkout-history-web-image.txt
secrets: inherit
69 changes: 0 additions & 69 deletions .github/workflows/build-from-main.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build latest from main and Auto Deploy to workshop

on:
workflow_run:
workflows: [ 'Run Tests' ]
branches: [ 'main' ]
types: [ completed ]


jobs:
build-unstable:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: mlibrary/platform-engineering-workflows/.github/workflows/build-unstable.yml@v1
with:
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.sha }}
dockerfile: Dockerfile
secrets: inherit

deploy-unstable:
needs: build-unstable
name: Deploy to workshop
uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1
with:
image: ${{ needs.build-unstable.outputs.image }}
file: environments/account/workshop/checkout-history-web-image.txt
secrets: inherit
52 changes: 0 additions & 52 deletions .github/workflows/deploy-production.yaml

This file was deleted.

67 changes: 9 additions & 58 deletions .github/workflows/manual-build-dev-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,15 @@ on:
description: tag
required: true


env:
IMAGE_NAME: circulation_history_dev_db
IMAGE_NAME: checkout-history-dev-db

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Clone latest repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check that the tag exists in repo
id: tag_check
run: |
if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then
echo '::set-output name=tag::${{ github.event.inputs.tag }}'
elif git rev-parse '${{ github.event.inputs.tag }}' &> /dev/null; then
echo "::set-output name=tag::`git rev-parse '${{ github.event.inputs.tag }}'`"
else
echo "Couldn't figure out tag from input: ${{ github.event.inputs.tag }}"
echo "Aborting deployment."
false
fi
- name: Log into Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check that the tag exists in container registry
id: image_check
run: |
if docker manifest inspect ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} > /dev/null; then
echo '::set-output name=image_exists::true'
echo "image exists!"
else
echo "image doesn't exist; Starting to Build and push image"
fi
- name: Checkout Correct repository
if: ${{ steps.image_check.outputs.image_exists != 'true' }}
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.tag }}
- name: Build and Push
if: ${{ steps.image_check.outputs.image_exists != 'true' }}
uses: docker/build-push-action@v2
with:
context: lib/dev_db/.
push: true
tags: |
ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:latest
ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}}
- name: Relabel as latest
if: ${{ steps.image_check.outputs.image_exists == 'true' }}
run: |
docker pull ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}}
docker tag ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:latest
docker push ghcr.io/mlibrary/${{ env.IMAGE_NAME }}:latest
build-unstable:
uses: mlibrary/platform-engineering-workflows/.github/workflows/build-unstable.yml@v1
with:
image_name: ${{ env.IMAGE_NAME }}
tag: ${{ github.event.inputs.tag }}
context: "lib/dev_db/."
dockerfile: Dockerfile
secrets: inherit
27 changes: 27 additions & 0 deletions .github/workflows/manual-deploy-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Manual Deploy to Production

on:
workflow_dispatch:
inputs:
tag:
description: Release
required: true

jobs:
build-production:
name: Build production ${{ github.event.inputs.tag }}
uses: mlibrary/platform-engineering-workflows/.github/workflows/build-production.yml@v1
with:
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.event.inputs.tag }}
dockerfile: Dockerfile
secrets: inherit

deploy-production:
needs: build-production
name: Deploy to production
uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1
with:
image: ghcr.io/mlibrary/${{ vars.IMAGE_NAME }}:${{ github.event.inputs.tag }}
file: environments/account/production/checkout-history-web-image.txt
secrets: inherit
74 changes: 0 additions & 74 deletions .github/workflows/manual-deploy-staging.yaml

This file was deleted.

Loading

0 comments on commit 1411185

Please sign in to comment.