test-success #3345
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dagger CI Workflow | |
on: | |
repository_dispatch: | |
types: [test-success] | |
workflow_dispatch: # manually triggered | |
env: | |
# Dagger | |
DAGGER_PLAN: cue.mod/pkg/github.com/3box/pipeline-tools/ci/plans/ceramic.cue | |
STATUS_PLAN: cue.mod/pkg/github.com/3box/pipeline-tools/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_DEFAULT_REGION }} | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
# Miscellaneous | |
RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
STATUS_URL: "https://api.github.com/repos/ceramicnetwork/js-ceramic/statuses/${{ github.event.client_payload.sha || github.sha }}" | |
BRANCH: ${{ github.event.client_payload.branch || github.ref_name }} | |
SHA: ${{ github.event.client_payload.sha || github.sha }} | |
jobs: | |
image: | |
name: Verify and publish Docker image | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
# Use specified SHA, otherwise use the branch | |
ref: ${{ github.event.client_payload.sha || env.BRANCH }} | |
- | |
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" | |
- | |
name: Set commit status "pending" | |
run: dagger do pending -p ${{ env.STATUS_PLAN }} | |
- | |
name: Set sha tag | |
run: | | |
SHA_TAG=$(echo ${{ env.SHA }} | head -c 12) | |
echo "SHA_TAG=$SHA_TAG" >> $GITHUB_ENV | |
- | |
name: Set main branch tag | |
if: ${{ env.BRANCH == 'main' }} | |
run: | | |
echo "DEPLOY_ENV=prod" >> $GITHUB_ENV | |
- | |
name: Set rc branch tag | |
if: ${{ env.BRANCH == 'release-candidate' }} | |
run: | | |
echo "DEPLOY_ENV=tnet" >> $GITHUB_ENV | |
- | |
name: Set develop branch tag | |
if: ${{ env.BRANCH == 'develop' || env.DEPLOY_ENV == '' }} | |
run: | | |
echo "DEPLOY_ENV=dev" >> $GITHUB_ENV | |
- | |
name: Set publish flag | |
if: ${{ env.BRANCH == 'main' || env.BRANCH == 'release-candidate' || env.BRANCH == 'develop' }} | |
run: echo "PUBLISH=true" >> $GITHUB_ENV | |
- | |
name: Get version | |
if: ${{ env.PUBLISH == 'true' }} | |
run: echo "VERSION=$(dagger do -l error --output-format json version -p ${{ env.DAGGER_PLAN }} | jq -r '.version')" >> $GITHUB_ENV | |
- | |
name: Push Docker image | |
if: ${{ env.PUBLISH == 'true' }} | |
run: dagger do push -w "actions:push:\"${{ env.AWS_REGION }}\":\"${{ env.DEPLOY_ENV }}\":\"${{ env.BRANCH }}\":\"${{ env.SHA }}\":\"${{ env.SHA_TAG }}\":\"${{ env.VERSION }}\":_" -p ${{ env.DAGGER_PLAN }} | |
- | |
name: Schedule k8s deployment | |
if: ${{ env.PUBLISH == 'true' }} | |
run: | | |
# Schedule deployment | |
make DEPLOY_ENV="$DEPLOY_ENV" DEPLOY_TAG=${{ env.SHA }} schedule-k8s-deployment | |
# Schedule post-deployment tests | |
make DEPLOY_ENV="$DEPLOY_ENV" TEST_SELECTOR="correctness/fast" schedule-tests | |
# If deploying to QA, also deploy to Dev and run post-deployment tests. | |
if [[ "$DEPLOY_ENV" == "qa" ]]; then | |
make DEPLOY_ENV="dev" DEPLOY_TAG=${{ env.SHA }} schedule-k8s-deployment | |
make DEPLOY_ENV="dev" TEST_SELECTOR="correctness/fast" schedule-tests | |
fi | |
- | |
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 }} |