diff --git a/.github/workflows/E2E.yml b/.github/workflows/E2E.yml index 6e093950..10e44d67 100644 --- a/.github/workflows/E2E.yml +++ b/.github/workflows/E2E.yml @@ -5,6 +5,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: e2e: timeout-minutes: 15 diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index 92f28e9e..abe2b10b 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -5,6 +5,10 @@ on: branches: ["main"] pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + permissions: contents: read pages: write diff --git a/.github/workflows/gitspiegel-trigger.yml b/.github/workflows/gitspiegel-trigger.yml deleted file mode 100644 index dce3aaf2..00000000 --- a/.github/workflows/gitspiegel-trigger.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: gitspiegel sync - -# This workflow doesn't do anything, it's only use is to trigger "workflow_run" -# webhook, that'll be consumed by gitspiegel -# This way, gitspiegel won't do mirroring, unless this workflow runs, -# and running the workflow is protected by GitHub - -on: - pull_request: - types: - - opened - - synchronize - - unlocked - - ready_for_review - - reopened - -jobs: - sync: - runs-on: ubuntu-latest - steps: - - name: Do nothing - run: echo "let's go" diff --git a/.github/workflows/publish-deploy.yml b/.github/workflows/publish-deploy.yml new file mode 100644 index 00000000..304089d0 --- /dev/null +++ b/.github/workflows/publish-deploy.yml @@ -0,0 +1,135 @@ +name: Publish and deploy + +on: + push: + branches: + - main + tags: + - v* + - stg-v* + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +#to use reusable workflow +permissions: + id-token: write + contents: read + +env: + APP: "substrate-faucet" + +jobs: + set-variables: + name: Set variables + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.version.outputs.VERSION }} + steps: + - name: Define version + id: version + run: | + export COMMIT_SHA=${{ github.sha }} + export COMMIT_SHA_SHORT=${COMMIT_SHA:0:8} + export REF_NAME=${{ github.ref_name }} + export REF_SLUG=${REF_NAME//\//_} + echo "short sha: ${COMMIT_SHA_SHORT} slug: ${REF_SLUG}" + if [[ ${REF_SLUG} == "main" ]] + then + export VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT} + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + else + export VERSION=${REF_SLUG} + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + fi + echo "set VERSION=${VERSION}" + build_push_docker: + name: Build docker image + runs-on: ubuntu-latest + environment: main_n_tags + needs: [set-variables] + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: | + docker.io/paritytech/faucet:${{ env.VERSION }} + + deploy-versi: + name: Deploy Versi + runs-on: ubuntu-latest + environment: parity-versi + needs: [set-variables, build_push_docker] + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + ARGOCD_SERVER: "versi-argocd.teleport.parity.io" + steps: + - name: Deploy to ArgoCD + uses: paritytech/argocd-deployment-action@main + with: + environment: "parity-versi" + tag: "${{ env.VERSION }}" + app_name: substrate-faucet-versi + app_packages: "${{ env.APP }}" + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: polkadot-testnet-faucet + teleport_app_name: "argocd-versi" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} + + deploy-westend: + name: Deploy Westend + runs-on: ubuntu-latest + environment: parity-testnet + if: startsWith(github.ref, 'refs/tags/v') + needs: [set-variables, build_push_docker] + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + ARGOCD_SERVER: "argocd-chains.teleport.parity.io" + steps: + - name: Deploy to ArgoCD + uses: paritytech/argocd-deployment-action@main + with: + environment: "parity-testnet" + tag: "${{ env.VERSION }}" + app_name: substrate-faucet-westend + app_packages: ${{ env.APP }} + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: polkadot-testnet-faucet + teleport_app_name: "argocd-chains" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} + + deploy-paseo: + name: Deploy Paseo + runs-on: ubuntu-latest + environment: parity-testnet + if: startsWith(github.ref, 'refs/tags/v') + needs: [set-variables, build_push_docker] + env: + VERSION: ${{ needs.set-variables.outputs.VERSION }} + ARGOCD_SERVER: "argocd-chains.teleport.parity.io" + steps: + - name: Deploy to ArgoCD + uses: paritytech/argocd-deployment-action@main + with: + environment: "parity-testnet" + tag: "${{ env.VERSION }}" + app_name: substrate-faucet-paseo + app_packages: ${{ env.APP }} + argocd_server: ${{ env.ARGOCD_SERVER }} + teleport_token: polkadot-testnet-faucet + teleport_app_name: "argocd-chains" + argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} diff --git a/.github/workflows/tag-client-pr.yml b/.github/workflows/tag-client-pr.yml index ca90784b..815fefc5 100644 --- a/.github/workflows/tag-client-pr.yml +++ b/.github/workflows/tag-client-pr.yml @@ -2,8 +2,12 @@ name: Label Client PRs on: pull_request_target: - paths: - - 'client/**' + paths: + - "client/**" + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true permissions: pull-requests: write diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index abb02a83..ccc94a0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,10 @@ on: branches: ["main"] pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + permissions: contents: read @@ -62,3 +66,21 @@ jobs: run: yarn install --immutable - run: yarn generate:papi - run: yarn test + build_image: + name: Build docker image + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + IMAGE_NAME: "docker.io/paritytech/faucet" + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: false + tags: | + ${{ env.IMAGE_NAME }}:latest diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 89c7f80a..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,177 +0,0 @@ - -stages: - - test - - build - - deploy - - publish-docker-description - -default: - interruptible: true - retry: - max: 2 - when: - - runner_system_failure - - unknown_failure - - api_failure - -variables: - KUBE_NAMESPACE: "faucetbots" - CI_REGISTRY: "docker.io/paritytech" - GIT_STRATEGY: fetch - CI_IMAGE: "docker.io/paritytech/eng-automation-ci:latest" - # BUILDAH_IMAGE is defined in group variables - BUILDAH_COMMAND: "buildah --storage-driver overlay2" - ARGOCD_IMAGE: argoproj/argocd:v2.5.5 - DOCKERHUB_REPO: "paritytech" - IMAGE_NAME: docker.io/$DOCKERHUB_REPO/faucet - DOCKER_TAG: "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" - -.common-refs: &common-refs - rules: - - if: $CI_PIPELINE_SOURCE == "web" - - if: $CI_PIPELINE_SOURCE == "schedule" - - if: $CI_COMMIT_REF_NAME == "main" - - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - -.pr-refs: &pr-refs - rules: - - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - -.publish-refs: &publish-refs - rules: - - if: $CI_COMMIT_REF_NAME == "main" # on commits to main branch - - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # on tags (i.e. v1.0, v2.1rc1) - - if: $CI_COMMIT_REF_NAME =~ /^stg-v[0-9]+\.[0-9]+.*$/ # on staging tags - -.deploy-stg-refs: &deploy-stg-refs - rules: - - if: $CI_COMMIT_REF_NAME == "main" # on commits to main branch - - if: $CI_COMMIT_REF_NAME =~ /^stg-v[0-9]+\.[0-9]+.*$/ # on staging tags - -.deploy-prod-refs: &deploy-prod-refs - rules: - - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # on tags (i.e. v1.0, v2.1rc1) - -.kubernetes-env: &kubernetes-env - image: $CI_IMAGE - tags: - - kubernetes-parity-build - -# template task for building and pushing an image - -.build-push-docker-image: &build-push-docker-image - image: $BUILDAH_IMAGE - script: - - test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" || - ( echo "no docker credentials provided"; exit 1 ) - - $BUILDAH_COMMAND build - --format=docker - --build-arg VCS_REF="${CI_COMMIT_SHA}" - --build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" - --build-arg VERSION="${DOCKER_TAG}" - --build-arg PROJECT_NAME="${CI_PROJECT_NAME}" - --tag "$IMAGE_NAME:${DOCKER_TAG}" - --tag "$IMAGE_NAME:latest" - --file "$DOCKERFILE" . - - echo "$Docker_Hub_Pass_Parity" | - buildah login --username "$Docker_Hub_User_Parity" --password-stdin docker.io - - $BUILDAH_COMMAND info - - $BUILDAH_COMMAND push --format=v2s2 "$IMAGE_NAME:${DOCKER_TAG}" - - $BUILDAH_COMMAND push --format=v2s2 "$IMAGE_NAME:latest" - after_script: - - buildah logout --all - -# test that docker image can build - -.build-only-docker-image: &build-only-docker-image - image: $BUILDAH_IMAGE - script: - - $BUILDAH_COMMAND build - --format=docker - --build-arg VCS_REF="${CI_COMMIT_SHA}" - --build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" - --build-arg PROJECT_NAME="${CI_PROJECT_NAME}" - --tag "$IMAGE_NAME:latest" - --file "$DOCKERFILE" . - - $BUILDAH_COMMAND info - -#### stage: build - -build-docker: - stage: build - <<: *pr-refs - <<: *kubernetes-env - <<: *build-only-docker-image - variables: - DOCKERFILE: "Dockerfile" - -publish-docker: - stage: build - <<: *publish-refs - <<: *kubernetes-env - <<: *build-push-docker-image - variables: - DOCKERFILE: "Dockerfile" - -#### stage: deploy - -.deploy-with-argocd: &deploy-with-argocd - image: $ARGOCD_IMAGE - tags: - - kubernetes-parity-build - variables: - ARGOCD_OPTS: --grpc-web --grpc-web-root-path /$DOMAIN - script: - - argocd app list - - argocd app set $APP --helm-set substrate-faucet.image.tag="${DOCKER_TAG}" - - argocd app sync $APP - - argocd app wait $APP --timeout 180 - -deploy-versi: - stage: deploy - <<: *deploy-stg-refs - extends: .deploy-with-argocd - environment: versi - variables: - DOMAIN: parity-versi - APP: substrate-faucet-versi - -deploy-westend: - stage: deploy - <<: *deploy-prod-refs - extends: .deploy-with-argocd - environment: westend - variables: - DOMAIN: parity-testnet - APP: substrate-faucet-westend - -deploy-paseo: - stage: deploy - <<: *deploy-prod-refs - extends: .deploy-with-argocd - environment: paseo - variables: - DOMAIN: parity-testnet - APP: substrate-faucet-paseo - -#### stage: publish-docker-description -.publish-docker-image-description: - stage: publish-docker-description - <<: *kubernetes-env - image: paritytech/dockerhub-description - variables: - DOCKER_USERNAME: $Docker_Hub_User_Parity - DOCKER_PASSWORD: $Docker_Hub_Pass_Parity - script: - - cd / && sh entrypoint.sh - -publish-docker-image-description-faucet: - extends: .publish-docker-image-description - variables: - DOCKERHUB_REPOSITORY: $DOCKERHUB_REPO/$IMAGE_NAME - README_FILEPATH: $CI_PROJECT_DIR/Dockerfile.README.md - SHORT_DESCRIPTION: "Generic Faucet for Substrate based chains" - rules: - - if: $CI_COMMIT_REF_NAME == "main" - changes: - - Dockerfile.README.md