diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..571326e --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,21 @@ +name: integration + +on: + push: + branches: [ master ] + +jobs: + publish: + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v2.0.0 + secrets: inherit + with: + DOCKERHUB_REPO: "aeternitybot/${{ github.event.repository.name }}" + deploy: + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@v2.0.0 + needs: [publish] + secrets: inherit + with: + DEPLOY_ENV: dev + DEPLOY_APP: ${{ github.event.repository.name }} + DEPLOY_VERSION: ${{ github.ref_name }} + DEPLOY_SUBDOMAIN: hyperchain diff --git a/.github/workflows/prod-docker.yml b/.github/workflows/prod-docker.yml deleted file mode 100644 index 5ba4753..0000000 --- a/.github/workflows/prod-docker.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Production Aepp Hyperchains UI - -on: - push: - branches: - - master - release: - types: [created] - -env: - ENV: "prd" - APP: "aepp-base-hc" - -jobs: - main: - runs-on: ubuntu-latest - name: Production Aepp Base Pipeline - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 100 - - - uses: GoogleCloudPlatform/release-please-action@v2 - id: release - with: - token: ${{ secrets.GITHUB_TOKEN }} - release-type: node - package-name: "" - changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"ci","section":"CI / CD","hidden":false},{"type":"test","section":"Testing","hidden":false},{"type":"refactor","section":"Refactorings","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]' - - - name: Set up Docker Buildx - id: buildx - # Use the action from the master, as we've seen some inconsistencies with @v1 - # Issue: https://github.com/docker/build-push-action/issues/286 - uses: docker/setup-buildx-action@master - # Only worked for us with this option on �‍♂️ - with: - install: true - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - # Key is named differently to avoid collision - key: ${{ runner.os }}-${{ env.ENV }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.ENV }}-buildx - - - name: Log in to dockerhub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_PASS }} - - - name: Extract metadata for docker - if: | - github.event_name == 'push' || - startsWith(github.ref, 'refs/tags/v') - id: meta - uses: docker/metadata-action@v3 - with: - images: aeternitybot/aepp-base-hc - tags: | - type=raw,value=latest,enable=${{ endsWith(GitHub.ref, 'master') }} - type=raw,value=${{ steps.release.outputs.tag_name }},enable=${{ endsWith(GitHub.ref, 'master') }} - type=ref,event=tag - type=ref,event=pr - - - name: Build and push docker image - if: | - github.event_name == 'push' || - startsWith(github.ref, 'refs/tags/v') - uses: docker/build-push-action@v2 - with: - context: . - file: Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - # Note the mode=max here - # More: https://github.com/moby/buildkit#--export-cache-options - # And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue - cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new - - - name: Move cache - if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize' - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - - uses: actions/checkout@v2 - with: - repository: aeternity/gitops-apps.git - ref: prd - persist-credentials: false - fetch-depth: 0 - - - name: Production Deploy - if: ${{ steps.release.outputs.release_created }} - uses: aeternity/ae-github-actions/argocd-deploy@v4 - with: - url-prefix: ${{ steps.release.outputs.tag_name }} - env: ${{ env.ENV }} - app: ${{ env.APP }} - - - name: Push changes - uses: ad-m/github-push-action@master - with: - repository: aeternity/gitops-apps - github_token: ${{ secrets.BOT_GITHUB_TOKEN }} - branch: prd diff --git a/.github/workflows/pull-request-cleanup.yml b/.github/workflows/pull-request-cleanup.yml new file mode 100644 index 0000000..6567780 --- /dev/null +++ b/.github/workflows/pull-request-cleanup.yml @@ -0,0 +1,22 @@ +name: pull-request-cleanup + +on: + pull_request: + branches: [ master ] + types: [ closed ] + +jobs: + rollback: + uses: aeternity/github-actions/.github/workflows/_rollback-gitops.yml@v2.0.0 + secrets: inherit + with: + DEPLOY_ENV: dev + DEPLOY_APP: ${{ github.event.repository.name }} + DEPLOY_VERSION: "pr-${{ github.event.number }}" + DEPLOY_SUBDOMAIN: "pr-${{ github.event.number }}-hyperchain" + delete-tag: + uses: aeternity/github-actions/.github/workflows/_delete-tag-docker.yml@v2.0.0 + secrets: inherit + with: + DOCKERHUB_REPO: "aeternitybot/${{ github.event.repository.name }}" + DOCKERHUB_TAG: "pr-${{ github.event.number }}" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..e975896 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,21 @@ +name: pull-request + +on: + pull_request: + branches: [ master ] + +jobs: + publish: + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v2.0.0 + secrets: inherit + with: + DOCKERHUB_REPO: "aeternitybot/${{ github.event.repository.name }}" + deploy: + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@v2.0.0 + needs: [publish] + secrets: inherit + with: + DEPLOY_ENV: dev + DEPLOY_APP: ${{ github.event.repository.name }} + DEPLOY_VERSION: "pr-${{ github.event.number }}" + DEPLOY_SUBDOMAIN: "pr-${{ github.event.number }}-hyperchain" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..99481b4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,19 @@ +name: release + +on: + push: + tags: [ v* ] + +jobs: + publish: + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v2.0.0 + secrets: inherit + deploy: + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@v2.0.0 + needs: [publish] + secrets: inherit + with: + DEPLOY_ENV: stg #TODO change to prd + DEPLOY_APP: ${{ github.event.repository.name }} + DEPLOY_TAG: ${{ github.ref_name }} + DEPLOY_SUBDOMAIN: hyperchain diff --git a/.github/workflows/staging-docker.yml b/.github/workflows/staging-docker.yml deleted file mode 100644 index 48bc755..0000000 --- a/.github/workflows/staging-docker.yml +++ /dev/null @@ -1,131 +0,0 @@ -name: Staging Aepp Hyperchains UI - -on: - pull_request: - branches: [ master, develop ] - types: [ opened, synchronize, closed ] - -env: - PR_NUMBER: ${{ github.event.pull_request.number }} - ENV: "dev" - APP: "aepp-hc-ui" - -jobs: - main: - runs-on: ubuntu-latest - name: Staging Aepp Base Pipeline - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Docker Buildx - id: buildx - # Use the action from the master, as we've seen some inconsistencies with @v1 - # Issue: https://github.com/docker/build-push-action/issues/286 - uses: docker/setup-buildx-action@master - # Only worked for us with this option on - with: - install: true - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - # Key is named differently to avoid collision - key: ${{ runner.os }}-${{ env.ENV }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-${{ env.ENV }}-buildx - - - name: Log in to dockerhub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_PASS }} - - - name: Extract metadata for docker - if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize' - id: meta - uses: docker/metadata-action@v3 - with: - images: aeternity/aepp-hc-ui - tags: | - type=raw,value=latest,enable=${{ endsWith(GitHub.ref, 'master') }} - type=ref,event=tag - type=ref,event=pr - - - name: Get commit sha on PR Sync - if: github.event_name == 'pull_request' && github.event.action == 'synchronize' - id: git-sha - shell: bash - run: | - echo "::set-output name=git-sha::$(git rev-parse --short HEAD)" - - - name: Build and push docker image - if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize' - uses: docker/build-push-action@v2 - with: - context: . - file: Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - # Note the mode=max here - # More: https://github.com/moby/buildkit#--export-cache-options - # And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue - cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new - - - name: Move cache - if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize' - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - - uses: actions/checkout@v2 - with: - repository: aeternity/gitops-apps.git - ref: dev - persist-credentials: false - fetch-depth: 0 - - - name: Staging PR Sync - if: github.event_name == 'pull_request' && github.event.action == 'synchronize' - uses: aeternity/ae-github-actions/argocd-pr-sync@v4 - with: - git-sha: ${{ steps.git-sha.outputs.git-sha }} - url-prefix: pr-${{ env.PR_NUMBER }} - env: ${{ env.ENV }} - app: ${{ env.APP }} - - - name: Staging deploy - if: github.event_name == 'pull_request' && github.event.action == 'opened' - uses: aeternity/ae-github-actions/argocd-deploy@v4 - with: - url-prefix: pr-${{ env.PR_NUMBER }} - env: ${{ env.ENV }} - app: ${{ env.APP }} - - - name: Staging undeploy - if: github.event_name == 'pull_request' && github.event.action == 'closed' && startsWith(github.head_ref, 'release') != true - uses: aeternity/ae-github-actions/argocd-undeploy@v4 - with: - url-prefix: pr-${{ env.PR_NUMBER }} - env: ${{ env.ENV }} - app: ${{ env.APP }} - - - name: Print PR url - uses: unsplash/comment-on-pr@v1.3.0 - if: github.event_name == 'pull_request' && github.event.action == 'opened' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - msg: Deployed to https://pr-${{ env.PR_NUMBER }}-${{ env.APP }}.${{ env.ENV }}.aepps.com - check_for_duplicate_msg: true - - - name: Push changes - uses: ad-m/github-push-action@master - with: - repository: aeternity/gitops-apps - github_token: ${{ secrets.BOT_GITHUB_TOKEN }} - branch: dev