diff --git a/.github/workflows/build-deploy-on-release.yaml b/.github/workflows/build-deploy-on-release.yaml new file mode 100644 index 0000000..be90d2b --- /dev/null +++ b/.github/workflows/build-deploy-on-release.yaml @@ -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 diff --git a/.github/workflows/build-from-main.yml b/.github/workflows/build-from-main.yml deleted file mode 100644 index 3a4aa18..0000000 --- a/.github/workflows/build-from-main.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Build latest from main and Auto Deploy to Testing and Staging - -on: - workflow_run: - workflows: [ 'Run Tests' ] - branches: [ 'main' ] - types: [ completed ] - - -jobs: - build: - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - environment: testing - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Log into Github Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and Push - uses: docker/build-push-action@v2 - with: - context: . - file: Dockerfile.prod - push: true - tags: | - ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:latest - ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.sha }} - - deploy-testing: - needs: build - runs-on: ubuntu-latest - environment: testing - steps: - - name: Deploy to Testing - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.sha }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history - - deploy-staging: - needs: build - runs-on: ubuntu-latest - environment: staging - steps: - - name: Deploy to Staging - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.sha }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml new file mode 100644 index 0000000..5cc5f77 --- /dev/null +++ b/.github/workflows/build-main.yml @@ -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 diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml deleted file mode 100644 index 94cddfa..0000000 --- a/.github/workflows/deploy-production.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: Deploy to Production - -on: - workflow_dispatch: - inputs: - tag: - description: Release - required: true - -jobs: - deploy: - runs-on: ubuntu-latest - environment: production - steps: - - name: Deploy to Production - uses: mlibrary/deploy-to-kubernetes@v1.1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.event.inputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history - - name: Deploy early cronjob - uses: mlibrary/deploy-to-kubernetes@v1.1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.event.inputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - type: cronjob - container: circulation-history - cronjob_name: circulation-history-loader-early - - name: Deploy later cronjob - uses: mlibrary/deploy-to-kubernetes@v1.1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ github.event.inputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - type: cronjob - container: circulation-history - cronjob_name: circulation-history-loader-later diff --git a/.github/workflows/manual-build-dev-db.yml b/.github/workflows/manual-build-dev-db.yml index dcfe86f..00827cd 100644 --- a/.github/workflows/manual-build-dev-db.yml +++ b/.github/workflows/manual-build-dev-db.yml @@ -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 diff --git a/.github/workflows/manual-deploy-production.yaml b/.github/workflows/manual-deploy-production.yaml new file mode 100644 index 0000000..3b7641e --- /dev/null +++ b/.github/workflows/manual-deploy-production.yaml @@ -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 diff --git a/.github/workflows/manual-deploy-staging.yaml b/.github/workflows/manual-deploy-staging.yaml deleted file mode 100644 index c9435c0..0000000 --- a/.github/workflows/manual-deploy-staging.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: Manual Deploy to Staging - -on: - workflow_dispatch: - inputs: - tag: - description: tag - required: true - - -env: - environment: staging - -jobs: - deploy: - runs-on: ubuntu-latest - environment: staging - 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/${{ secrets.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: . - file: Dockerfile.prod - push: true - tags: ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} - - name: Deploy to ${{ env.environment }} - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history diff --git a/.github/workflows/manual-deploy-testing.yaml b/.github/workflows/manual-deploy-testing.yaml deleted file mode 100644 index 64c9895..0000000 --- a/.github/workflows/manual-deploy-testing.yaml +++ /dev/null @@ -1,73 +0,0 @@ -name: Manual Deploy to Testing - -on: - workflow_dispatch: - inputs: - tag: - description: tag - required: true - -env: - environment: testing - -jobs: - deploy: - runs-on: ubuntu-latest - environment: testing - 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/${{ secrets.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: . - file: Dockerfile.prod - push: true - tags: ghcr.io/mlibrary/${{ secrets.IMAGE_NAME }}:${{steps.tag_check.outputs.tag}} - - name: Deploy to ${{ env.environment }} - uses: mlibrary/deploy-to-kubernetes@v1 - with: - github_username: ${{ github.actor }} - github_token: ${{ secrets.GITHUB_TOKEN }} - image: mlibrary/${{ secrets.IMAGE_NAME }}:${{ steps.tag_check.outputs.tag }} - cluster_ca: ${{ secrets.HATCHER_CLUSTER_CA }} - cluster_server: https://hatcher.kubernetes.lib.umich.edu - namespace_token: ${{ secrets.HATCHER_TOKEN }} - namespace: ${{ secrets.NAMESPACE }} - deployment: circulation-history-web - container: circulation-history diff --git a/.github/workflows/manual-deploy-workshop.yaml b/.github/workflows/manual-deploy-workshop.yaml new file mode 100644 index 0000000..c729f81 --- /dev/null +++ b/.github/workflows/manual-deploy-workshop.yaml @@ -0,0 +1,27 @@ +name: Manual Deploy to Workshop + +on: + workflow_dispatch: + inputs: + tag: + description: tag + required: true + +jobs: + build-unstable: + uses: mlibrary/platform-engineering-workflows/.github/workflows/build-unstable.yml@v1 + with: + image_name: ${{ vars.IMAGE_NAME }} + tag: ${{ github.event.inputs.tag }} + dockerfile: Dockerfile + secrets: inherit + + deploy-workshop: + needs: build-unstable + name: Deploy to workshop + uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1 + with: + environment: aim + image: ${{ needs.build-unstable.outputs.image }} + file: environments/account/workshop/checkout-history-web-image.txt + secrets: inherit diff --git a/.github/workflows/tag-release.yaml b/.github/workflows/tag-release.yaml deleted file mode 100644 index ac0fdd9..0000000 --- a/.github/workflows/tag-release.yaml +++ /dev/null @@ -1,27 +0,0 @@ - -name: Docker Tag Latest Release - -on: - release: - types: [ released ] - -env: - PROD_IMAGE_ID: ghcr.io/mlibrary/circulation_history - UNSTABLE_IMAGE_ID: ghcr.io/mlibrary/circulation_history_unstable -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Clone latest repository - uses: actions/checkout@v2 - - name: Tag latest release in Github Container Registry - run: | - docker pull $UNSTABLE_IMAGE_ID:${{ github.sha }} - docker tag $UNSTABLE_IMAGE_ID:${{ github.sha }} $PROD_IMAGE_ID:${{ github.event.release.tag_name }} - docker tag $UNSTABLE_IMAGE_ID:${{ github.sha }} $PROD_IMAGE_ID:latest - docker push $PROD_IMAGE_ID:${{ github.event.release.tag_name }} - docker push $PROD_IMAGE_ID:latest