Skip to content

fix(cd): add new stage for dequeued jobs that need preparation #449

fix(cd): add new stage for dequeued jobs that need preparation

fix(cd): add new stage for dequeued jobs that need preparation #449

Workflow file for this run

name: CD Manager
on:
push:
branches: [ develop, qa, tnet, main ]
paths:
- 'cd/manager/**'
pull_request: # pull requests
workflow_dispatch: # manually triggered
inputs:
environment:
description: 'Environment name (one of: dev, qa, tnet, prod)'
required: true
default: 'dev'
env:
# Dagger
DAGGER_PLAN: ci/plans/cd-manager.cue
STATUS_PLAN: ci/plans/status.cue
DAGGER_LOG_FORMAT: "plain"
# Secrets
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# GitHub
RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
STATUS_URL: "https://api.github.com/repos/3box/pipeline-tools/statuses/${{ github.sha }}"
BRANCH: ${{ github.head_ref || github.ref_name }}
SHA: ${{ github.sha }}
jobs:
handle_docker_image:
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v2
with:
ref: ${{ env.BRANCH }}
-
name: Set sha tag
run: |
SHA=$(git rev-parse HEAD)
SHA_TAG=$(git rev-parse --short=12 HEAD)
echo "SHA=$SHA" >> $GITHUB_ENV
echo "SHA_TAG=$SHA_TAG" >> $GITHUB_ENV
-
name: Set main branch tag
if: ${{ env.BRANCH == 'main' }}
run: |
echo "ENV_TAG=prod" >> $GITHUB_ENV
-
name: Set rc branch tag
if: ${{ env.BRANCH == 'tnet' }}
run: |
echo "ENV_TAG=tnet" >> $GITHUB_ENV
-
name: Set qa branch tag
if: ${{ env.BRANCH == 'qa' }}
run: |
echo "ENV_TAG=qa" >> $GITHUB_ENV
-
name: Set develop branch tag
if: ${{ env.BRANCH == 'develop' || env.ENV_TAG == '' }}
run: |
echo "ENV_TAG=dev" >> $GITHUB_ENV
-
name: Override env tag
if: ${{ github.event.inputs.environment != '' }}
run: |
echo "ENV_TAG=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
-
name: Install Dagger
uses: dagger/dagger-for-github@v3
with:
install-only: true
version: "0.2.36"
-
name: Setup Dagger
run: |
dagger project init
dagger project update
dagger project update "github.com/3box/pipeline-tools/ci@${{ env.SHA }}"
-
name: Set commit status "pending"
run: dagger do pending -p ${{ env.STATUS_PLAN }}
-
name: Verify Docker image
run: dagger do verify -p ../../${{ env.DAGGER_PLAN }}
working-directory: cd/manager
-
name: Push Docker image
if: ${{ env.BRANCH == 'main' || env.BRANCH == 'tnet' || env.BRANCH == 'qa' || env.BRANCH == 'develop' }}
run: dagger do push -w "actions:push:\"${{ env.AWS_REGION }}\":\"${{ env.ENV_TAG }}\":\"${{ env.BRANCH }}\":\"${{ env.SHA }}\":\"${{ env.SHA_TAG }}\":_" -p ../../${{ env.DAGGER_PLAN }}
working-directory: cd/manager
-
name: Restart service
if: ${{ env.BRANCH == 'main' || env.BRANCH == 'tnet' || env.BRANCH == 'qa' || env.BRANCH == 'develop' }}
shell: bash
run: |
cd .github/workflows/scripts
chmod +x stopTasks.sh
./stopTasks.sh "ceramic-${{ env.ENV_TAG }}-ops" "ceramic-${{ env.ENV_TAG }}-ops-cd-manager"
-
name: Set commit status "success"
run: dagger do success -p ${{ env.STATUS_PLAN }}
-
name: Set commit status "failure"
if: ${{ failure() }}
run: dagger do failure -p ${{ env.STATUS_PLAN }}