diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index 31c4eeb38a..0000000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,133 +0,0 @@ -name: Checks -on: - workflow_call: - workflow_dispatch: - pull_request: - types: [ opened, synchronize, unlabeled ] - paths-ignore: - - '.github/ISSUE_TEMPLATE/**' - - '.husky/**' - - '.vscode/**' - - 'deploy/**' - - 'docs/**' - - 'public/**' - - 'stub/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - code_quality: - name: Code quality - runs-on: ubuntu-latest - if: ${{ !contains(github.event.pull_request.labels.*.name, 'WIP') && !(github.event.action == 'unlabeled' && github.event.label.name != 'WIP') }} - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - - name: Cache node_modules - uses: actions/cache@v3 - id: cache-node-modules - with: - path: | - node_modules - key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn --frozen-lockfile - - - name: Run ESLint - run: yarn lint:eslint - - - name: Compile TypeScript - run: yarn lint:tsc - - jest_tests: - name: Jest tests - needs: [ code_quality ] - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - - name: Cache node_modules - uses: actions/cache@v3 - id: cache-node-modules - with: - path: | - node_modules - key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn --frozen-lockfile - - - name: Run Jest - run: yarn test:jest - - pw_tests: - name: 'Playwright tests / Project: ${{ matrix.project }}' - needs: [ code_quality ] - runs-on: ubuntu-latest - container: - image: mcr.microsoft.com/playwright:v1.35.1-focal - - strategy: - fail-fast: false - matrix: - project: [ default, mobile, dark-color-mode ] - - steps: - - name: Install git-lfs - run: apt-get update && apt-get install git-lfs - - - name: Checkout repo - uses: actions/checkout@v3 - with: - lfs: 'true' - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - - name: Cache node_modules - uses: actions/cache@v3 - id: cache-node-modules - with: - path: | - node_modules - key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn --frozen-lockfile - - - name: Run PlayWright - run: yarn test:pw:ci - env: - HOME: /root - PW_PROJECT: ${{ matrix.project }} - - - name: Upload test results - if: always() - uses: actions/upload-artifact@v3 - with: - name: playwright-report-${{ matrix.project }} - path: playwright-report - retention-days: 10 \ No newline at end of file diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml deleted file mode 100644 index 759b120b17..0000000000 --- a/.github/workflows/cleanup.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Cleanup environments - -on: - pull_request: - types: - - closed - - merged - workflow_dispatch: - -jobs: - cleanup_release: - uses: blockscout/blockscout-ci-cd/.github/workflows/cleanup_helmfile.yaml@master - with: - appName: review-l2-$GITHUB_REF_NAME_SLUG - globalEnv: review - helmfileDir: deploy - kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev - vaultRole: ci-dev - secrets: inherit - cleanup_l2_release: - uses: blockscout/blockscout-ci-cd/.github/workflows/cleanup_helmfile.yaml@master - with: - appName: review-$GITHUB_REF_NAME_SLUG - globalEnv: review - helmfileDir: deploy - kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev - vaultRole: ci-dev - secrets: inherit - cleanup_docker_image: - uses: blockscout/blockscout-ci-cd/.github/workflows/cleanup_docker.yaml@master - with: - dockerImage: prerelease-$GITHUB_REF_NAME_SLUG - secrets: inherit diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml deleted file mode 100644 index 670bbb8944..0000000000 --- a/.github/workflows/deploy-main.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Deploy from main branch - -on: - push: - branches: - - main - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - publish_image: - name: Publish Docker image - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - # Will automatically make nice tags, see the table here https://github.com/docker/metadata-action#basic - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/blockscout/frontend - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Add SHORT_SHA env property with commit short sha - run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - push: true - cache-from: type=gha - cache-to: type=gha,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - GIT_COMMIT_SHA=${{ env.SHORT_SHA }} - - deploy_main: - name: Deploy frontend - needs: publish_image - uses: blockscout/blockscout-ci-cd/.github/workflows/deploy_helmfile.yaml@master - with: - appName: front - globalEnv: main - helmfileDir: deploy - kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev - vaultRole: ci-dev - secrets: inherit - - deploy_l2: - name: Deploy frontend (L2) - needs: publish_image - uses: blockscout/blockscout-ci-cd/.github/workflows/deploy_helmfile.yaml@master - with: - appName: l2-optimism-goerli - globalEnv: optimism-goerli - helmfileDir: deploy - kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev - vaultRole: ci-dev - secrets: inherit diff --git a/.github/workflows/deploy-review-l2.yml b/.github/workflows/deploy-review-l2.yml deleted file mode 100644 index cf87e4b53d..0000000000 --- a/.github/workflows/deploy-review-l2.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Deploy review environment (L2) - -on: - workflow_dispatch: - -jobs: - publish_image: - name: Publish Docker image - runs-on: ubuntu-latest - outputs: - shortSha: ${{ steps.output-step.outputs.short-sha }} - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v4.4.1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - # Will automatically make nice tags, see the table here https://github.com/docker/metadata-action#basic - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/blockscout/frontend - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Add SHORT_SHA env property with commit short sha - run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV - - - name: Add outputs - run: | - echo "::set-output name=short-sha::${{ env.SHORT_SHA }}" - id: output-step - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - push: true - cache-from: type=gha - tags: ghcr.io/blockscout/frontend:prerelease-${{ env.GITHUB_REF_NAME_SLUG }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - GIT_COMMIT_SHA=${{ env.SHORT_SHA }} - - deploy_review_l2: - name: Deploy frontend (L2) - needs: publish_image - uses: blockscout/blockscout-ci-cd/.github/workflows/deploy_helmfile.yaml@master - with: - appName: review-l2-$GITHUB_REF_NAME_SLUG - globalEnv: review - helmfileDir: deploy - kubeConfigSecret: ci/data/dev/kubeconfig/k8s-dev - vaultRole: ci-dev - secrets: inherit diff --git a/.github/workflows/deploy-subspace.yml b/.github/workflows/deploy-subspace.yml index 72735167a6..c0e346d50a 100644 --- a/.github/workflows/deploy-subspace.yml +++ b/.github/workflows/deploy-subspace.yml @@ -16,12 +16,12 @@ env: # cancel-in-progress: true jobs: - make_slug: - name: Make GitHub reference slug + publish_image: + name: Publish Docker image runs-on: ubuntu-latest steps: - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v4.4.1 + - name: Check out the repo + uses: actions/checkout@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -55,5 +55,3 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | GIT_COMMIT_SHA=${{ env.SHORT_SHA }} - - diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 6aab1f48ff..c788e5f626 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -4,15 +4,61 @@ on: workflow_dispatch: workflow_call: -# concurrency: -# group: ${{ github.workflow }}__${{ github.job }}__${{ github.ref }} -# cancel-in-progress: true +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: publish_image: name: Publish Docker image - uses: './.github/workflows/publish-image.yml' - secrets: inherit + runs-on: ubuntu-latest + outputs: + shortSha: ${{ steps.output-step.outputs.short-sha }} + tags: ${{ steps.meta.outputs.tags }} + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4.4.1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Will automatically make nice tags, see the table here https://github.com/docker/metadata-action#basic + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/blockscout/frontend + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Add SHORT_SHA env property with commit short sha + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV + + - name: Add outputs + run: | + echo "::set-output name=short-sha::${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" + id: output-step + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + push: true + cache-from: type=gha + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + GIT_COMMIT_SHA=${{ env.SHORT_SHA }} + GIT_TAG=${{ github.ref_type == 'tag' && github.ref_name || '' }} deploy_e2e: name: Deploy E2E instance @@ -37,7 +83,7 @@ jobs: with: owner: blockscout repo: deployment-values - github_token: ${{ env.WORKFLOW_TRIGGER_TOKEN }} + github_token: ${{env.WORKFLOW_TRIGGER_TOKEN}} workflow_file_name: deploy_blockscout.yaml ref: main wait_interval: 30 @@ -47,4 +93,4 @@ jobs: name: Run tests needs: deploy_e2e uses: blockscout/blockscout-ci-cd/.github/workflows/e2e_new.yaml@master - secrets: inherit \ No newline at end of file + secrets: inherit diff --git a/.github/workflows/label-issues-in-release.yml b/.github/workflows/label-issues-in-release.yml deleted file mode 100644 index 5e4a9a7b5d..0000000000 --- a/.github/workflows/label-issues-in-release.yml +++ /dev/null @@ -1,281 +0,0 @@ -name: Label issues in release - -on: - workflow_dispatch: - inputs: - tag: - description: 'Release tag' - required: true - type: string - label_name: - description: 'Name of the label' - required: true - type: string - label_description: - description: 'Description of the label' - default: '' - required: false - type: string - label_color: - description: 'A color of the added label' - default: 'FFFFFF' - required: false - type: string - workflow_call: - inputs: - tag: - description: 'Release tag' - required: true - type: string - label_name: - description: 'Name of the label' - required: true - type: string - label_description: - description: 'Description of the label' - default: '' - required: false - type: string - label_color: - description: 'A color of the added label' - default: 'FFFFFF' - required: false - type: string - outputs: - issues: - description: "JSON encoded list of issues linked to commits in the release" - value: ${{ jobs.run.outputs.issues }} - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - run: - name: Run - runs-on: ubuntu-latest - outputs: - issues: ${{ steps.linked_issues.outputs.result }} - steps: - - name: Getting tags of the two latestest releases - id: tags - uses: actions/github-script@v6 - env: - TAG: ${{ inputs.tag }} - with: - script: | - const { repository: { releases: { nodes: releases } } } = await github.graphql(` - query ($owner: String!, $repo: String!) { - repository(owner: $owner, name: $repo) { - releases(first: 10, orderBy: { field: CREATED_AT, direction: DESC }) { - nodes { - name - tagName - tagCommit { - oid - } - isPrerelease - isDraft - publishedAt - } - } - } - } - `, - { - owner: context.repo.owner, - repo: context.repo.repo, - } - ); - - if (releases[0].tagName !== process.env.TAG) { - core.setFailed(`Release with tag ${ process.env.TAG } is not latest one.`); - return; - } - - const latestTag = process.env.TAG; - const [ { tagName: previousTag } ] = releases - .slice(1) - .filter(({ isDraft }) => !isDraft); - - core.info('Found following tags:'); - core.info(` latest: ${ latestTag }`); - core.info(` second latest: ${ previousTag }`); - - core.setOutput('latest', latestTag); - core.setOutput('previous', previousTag); - - - name: Looking for commits between two releases - id: commits - uses: actions/github-script@v6 - env: - PREVIOUS_TAG: ${{ steps.tags.outputs.previous }} - LATEST_TAG: ${{ steps.tags.outputs.latest }} - with: - script: | - const { data: { commits: commitsInRelease } } = await github.request('GET /repos/{owner}/{repo}/compare/{basehead}', { - owner: context.repo.owner, - repo: context.repo.repo, - basehead: `${ process.env.PREVIOUS_TAG }...${ process.env.LATEST_TAG }`, - }); - - if (commitsInRelease.length === 0) { - core.notice(`No commits found between ${ process.env.PREVIOUS_TAG } and ${ process.env.LATEST_TAG }`); - return []; - } - - const commits = commitsInRelease.map(({ sha }) => sha); - - core.startGroup(`Found ${ commits.length } commits`); - commits.forEach((sha) => { - core.info(sha); - }) - core.endGroup(); - - return commits; - - - name: Looking for issues linked to commits - id: linked_issues - uses: actions/github-script@v6 - env: - COMMITS: ${{ steps.commits.outputs.result }} - with: - script: | - const commits = JSON.parse(process.env.COMMITS); - - if (commits.length === 0) { - return []; - } - - const map = {}; - - core.startGroup(`Looking for linked issues`); - for (const sha of commits) { - const result = await getLinkedIssuesForCommitPR(sha); - result.forEach((issue) => { - map[issue] = issue; - }); - } - core.endGroup(); - - const issues = Object.values(map); - - if (issues.length > 0) { - core.startGroup(`Found ${ issues.length } unique issues`); - issues.sort().forEach((issue) => { - core.info(`#${ issue } - https://github.com/${ context.repo.owner }/${ context.repo.repo }/issues/${ issue }`); - }) - core.endGroup(); - } else { - core.notice('No linked issues found.'); - } - - return issues; - - async function getLinkedIssuesForCommitPR(sha) { - core.info(`Fetching issues for commit: ${ sha }`); - - const response = await github.graphql(` - query ($owner: String!, $repo: String!, $sha: GitObjectID!) { - repository(owner: $owner, name: $repo) { - object(oid: $sha) { - ... on Commit { - associatedPullRequests(first: 10) { - nodes { - number - title - state - merged - closingIssuesReferences(first: 10) { - nodes { - number - title - closed - } - } - } - } - } - } - } - } - `, { - owner: context.repo.owner, - repo: context.repo.repo, - sha, - }); - - if (!response) { - core.info('Nothing has found.'); - return []; - } - - const { repository: { object: { associatedPullRequests } } } = response; - - const issues = associatedPullRequests - .nodes - .map(({ closingIssuesReferences: { nodes: issues } }) => issues.map(({ number }) => number)) - .flat(); - - core.info(`Found following issues: ${ issues.join(', ') || '-' }\n`); - - return issues; - } - - - name: Creating label - id: label_creating - uses: actions/github-script@v6 - env: - LABEL_NAME: ${{ inputs.label_name }} - LABEL_COLOR: ${{ inputs.label_color }} - LABEL_DESCRIPTION: ${{ inputs.label_description }} - with: - script: | - try { - const result = await github.request('POST /repos/{owner}/{repo}/labels', { - owner: context.repo.owner, - repo: context.repo.repo, - name: process.env.LABEL_NAME, - color: process.env.LABEL_COLOR, - description: process.env.LABEL_DESCRIPTION, - }); - - core.info('Label was created.'); - } catch (error) { - if (error.status === 422) { - core.info('Label already exist.'); - } else { - core.setFailed(error.message); - } - } - - - - name: Adding label to issues - id: labeling_issues - uses: actions/github-script@v6 - env: - LABEL_NAME: ${{ inputs.label_name }} - ISSUES: ${{ steps.linked_issues.outputs.result }} - with: - script: | - const issues = JSON.parse(process.env.ISSUES); - - if (issues.length === 0) { - core.notice('No issues has found. Nothing to label.'); - return; - } - - for (const issue of issues) { - core.info(`Adding label to the issue #${ issue }...`); - await addLabelToIssue(issue, process.env.LABEL_NAME); - core.info('Done.\n'); - } - - async function addLabelToIssue(issue, label) { - return await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', { - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue, - labels: [ label ], - }); - } diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml deleted file mode 100644 index cf52dd4b4f..0000000000 --- a/.github/workflows/pre-release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Pre-release - -on: - workflow_dispatch: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+-[a-z]+' # e.g v1.2.3-alpha - -jobs: - checks: - name: Run code checks - uses: "./.github/workflows/checks.yml" - secrets: inherit - - e2e_tests: - name: Run e2e tests - needs: checks - uses: "./.github/workflows/e2e-tests.yml" - secrets: inherit - - label_issues: - name: Add pre-release label to issues - uses: './.github/workflows/label-issues-in-release.yml' - with: - tag: ${{ github.ref_name }} - label_name: 'pre-release' - secrets: inherit diff --git a/.github/workflows/project-management.yml b/.github/workflows/project-management.yml deleted file mode 100644 index 791515b07d..0000000000 --- a/.github/workflows/project-management.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Project management -on: - issues: - types: [ closed ] - pull_request: - types: [ review_requested ] - -jobs: - not_planned_issue: - name: Update task for not planned issue - if: ${{ github.event.issue && github.event.action == 'closed' && github.event.issue.state_reason == 'not_planned' }} - uses: './.github/workflows/update-project-cards.yml' - with: - project_name: ${{ vars.PROJECT_NAME }} - field_name: Status - field_value: Done - issues: "[${{ github.event.issue.number }}]" - secrets: inherit - - completed_issue: - name: Update task for completed issue - if: ${{ github.event.issue && github.event.action == 'closed' && github.event.issue.state_reason == 'completed' }} - uses: './.github/workflows/update-project-cards.yml' - with: - project_name: ${{ vars.PROJECT_NAME }} - field_name: Status - field_value: Ready For Realease - issues: "[${{ github.event.issue.number }}]" - secrets: inherit - - review_requested_issues: - name: Get issues linked to PR - runs-on: ubuntu-latest - if: ${{ github.event.pull_request && github.event.action == 'review_requested' }} - outputs: - issues: ${{ steps.linked_issues.outputs.result }} - steps: - - name: Fetching issues linked to pull request - id: linked_issues - uses: actions/github-script@v6 - env: - PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} - with: - script: | - const response = await github.graphql(` - query ($owner: String!, $repo: String!, $pr: Int!) { - repository(owner: $owner, name: $repo) { - pullRequest(number: $pr) { - number - title - closingIssuesReferences(first: 100) { - nodes { - number - title - closed - } - } - } - } - } - `, { - owner: context.repo.owner, - repo: context.repo.repo, - pr: Number(process.env.PULL_REQUEST_NUMBER), - }); - - const { repository: { pullRequest: { closingIssuesReferences } } } = response; - const issues = closingIssuesReferences.nodes.map(({ number }) => number); - - if (!issues.length) { - core.notice(`No linked issues found for pull request #${ process.env.PULL_REQUEST_NUMBER }`); - return; - } - - core.info(`Found ${ issues.length } issue(s): ${ issues.join(', ') || '-' }`); - - return issues; - - review_requested_tasks: - name: Update status for issues in review - needs: [ review_requested_issues ] - if: ${{ needs.review_requested_issues.outputs.issues }} - uses: './.github/workflows/update-project-cards.yml' - secrets: inherit - with: - project_name: ${{ vars.PROJECT_NAME }} - field_name: Status - field_value: Review - issues: ${{ needs.review_requested_issues.outputs.issues }} diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml deleted file mode 100644 index ba0382b078..0000000000 --- a/.github/workflows/publish-image.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Publish Docker image - -on: - workflow_dispatch: - inputs: - tags: - description: Image tags - required: false - type: string - platforms: - description: Image platforms (you can specify multiple platforms separated by comma) - required: false - type: string - default: linux/amd64 - workflow_call: - inputs: - tags: - description: Image tags - required: false - type: string - platforms: - description: Image platforms (you can specify multiple platforms separated by comma) - required: false - type: string - default: linux/amd64 - -jobs: - run: - name: Run - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - # Will automatically make nice tags, see the table here https://github.com/docker/metadata-action#basic - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/blockscout/frontend - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Add SHORT_SHA env property with commit short sha - run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV - - - name: Debug - env: - REF_TYPE: ${{ github.ref_type }} - REF_NAME: ${{ github.ref_name }} - run: | - echo "ref_type: $REF_TYPE" - echo "ref_name: $REF_NAME" - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - push: true - cache-from: type=gha - tags: ${{ inputs.tags || steps.meta.outputs.tags }} - platforms: ${{ inputs.platforms }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - GIT_COMMIT_SHA=${{ env.SHORT_SHA }} - GIT_TAG=${{ github.ref_type == 'tag' && github.ref_name || '' }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index cf1cfd6e70..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: Release - -on: - workflow_dispatch: - release: - types: [ released ] - -jobs: - remove_prerelease_label: - name: Remove pre-release label from issues - runs-on: ubuntu-latest - steps: - - name: Remove label - id: tags - uses: actions/github-script@v6 - env: - LABEL_NAME: pre-release - with: - script: | - const { data: issues } = await github.request('GET /repos/{owner}/{repo}/issues', { - owner: context.repo.owner, - repo: context.repo.repo, - labels: process.env.LABEL_NAME, - state: 'all' - }); - - const issueIds = issues.map(({ node_id }) => node_id); - const labelId = issues[0].labels.find(({ name }) => name === process.env.LABEL_NAME).node_id; - - core.info(`Found ${ issueIds.length } issues with label "${ process.env.LABEL_NAME }"`); - - for (const issueId of issueIds) { - core.info(`Removing label for issue with node_id ${ issueId }...`); - - await github.graphql(` - mutation($input: RemoveLabelsFromLabelableInput!) { - removeLabelsFromLabelable(input: $input) { - clientMutationId - } - } - `, { - input: { - labelIds: [ labelId ], - labelableId: issueId - }, - }); - - core.info('Done.\n'); - } - - - label_released_issues: - name: Label released issues - uses: './.github/workflows/label-issues-in-release.yml' - with: - tag: ${{ github.ref_name }} - label_name: ${{ github.ref_name }} - label_description: Release ${{ github.ref_name }} - secrets: inherit - - update_project_cards: - name: Update project tasks statuses - needs: label_released_issues - uses: './.github/workflows/update-project-cards.yml' - with: - project_name: ${{ vars.PROJECT_NAME }} - field_name: Status - field_value: Released - issues: ${{ needs.label_released_issues.outputs.issues }} - secrets: inherit - - # TODO @tom2drum refactor to reusable workflow - publish_image: - name: Publish Docker image - runs-on: ubuntu-latest - outputs: - shortSha: ${{ steps.output-step.outputs.short-sha }} - tags: ${{ steps.meta.outputs.tags }} - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v4.4.1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - # Will automatically make nice tags, see the table here https://github.com/docker/metadata-action#basic - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/blockscout/frontend - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Add SHORT_SHA env property with commit short sha - run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV - - - name: Debug - env: - REF_TYPE: ${{ github.ref_type }} - REF_NAME: ${{ github.ref_name }} - run: | - echo "ref_type: $REF_TYPE" - echo "ref_name: $REF_NAME" - - - name: Add outputs - run: | - echo "::set-output name=short-sha::${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" - id: output-step - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - push: true - cache-from: type=gha - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - GIT_COMMIT_SHA=${{ env.SHORT_SHA }} - GIT_TAG=${{ github.ref_type == 'tag' && github.ref_name || '' }} diff --git a/.github/workflows/update-project-cards.yml b/.github/workflows/update-project-cards.yml deleted file mode 100644 index 98ffbed2bb..0000000000 --- a/.github/workflows/update-project-cards.yml +++ /dev/null @@ -1,240 +0,0 @@ -name: Update project cards for issues - -on: - workflow_dispatch: - inputs: - project_name: - description: Name of the project - default: Front-end tasks - required: true - type: string - field_name: - description: Field name to be updated - default: Status - required: true - type: string - field_value: - description: New value of the field - default: Released - required: true - type: string - issues: - description: JSON encoded list of issue numbers to be updated - required: true - type: string - workflow_call: - inputs: - project_name: - description: Name of the project - required: true - type: string - field_name: - description: Field name to be updated - required: true - type: string - field_value: - description: New value of the field - required: true - type: string - issues: - description: JSON encoded list of issue numbers to be updated - required: true - type: string - -jobs: - run: - name: Run - runs-on: ubuntu-latest - steps: - - name: Getting project info - id: project_info - uses: actions/github-script@v6 - env: - PROJECT_NAME: ${{ inputs.project_name }} - FIELD_NAME: ${{ inputs.field_name }} - FIELD_VALUE: ${{ inputs.field_value }} - with: - github-token: ${{ secrets.BOT_LABEL_ISSUE_TOKEN }} - script: | - const response = await github.graphql(` - query ($login: String!, $q: String!) { - organization(login: $login) { - projectsV2(query: $q, first: 1) { - nodes { - id, - title, - number, - fields(first: 20) { - nodes { - ... on ProjectV2Field { - id - name - } - ... on ProjectV2SingleSelectField { - id - name - options { - id - name - } - } - } - } - } - } - } - } - `, { - login: context.repo.owner, - q: process.env.PROJECT_NAME, - }); - - const { organization: { projectsV2: { nodes: projects } } } = response; - - if (projects.length === 0) { - core.setFailed('Project not found.'); - return; - } - - if (projects.length > 1) { - core.info(`Fould ${ projects.length } with the similar name:`); - projects.forEach((issue) => { - core.info(` #${ projects.number } - ${ projects.title }`); - }) - core.setFailed('Fould multiple projects with the similar name. Cannot determine which one to use.'); - return; - } - - const { id: projectId, fields: { nodes: fields } } = projects[0]; - const field = fields.find((field) => field.name === process.env.FIELD_NAME); - - if (!field) { - core.setFailed(`Field with name "${ process.env.FIELD_NAME }" not found in the project.`); - return; - } - - const option = field.options.find((option) => option.name === process.env.FIELD_VALUE); - - if (!option) { - core.setFailed(`Option with name "${ process.env.FIELD_VALUE }" not found in the field possible values.`); - return; - } - - core.info('Found following info:'); - core.info(` project_id: ${ projectId }`); - core.info(` field_id: ${ field.id }`); - core.info(` field_value_id: ${ option.id }`); - - core.setOutput('id', projectId); - core.setOutput('field_id', field.id); - core.setOutput('field_value_id', option.id); - - - name: Getting project items that linked to the issues - id: items - uses: actions/github-script@v6 - env: - ISSUES: ${{ inputs.issues }} - with: - github-token: ${{ secrets.BOT_LABEL_ISSUE_TOKEN }} - script: | - const result = []; - const issues = JSON.parse(process.env.ISSUES); - - for (const issue of issues) { - const response = await getProjectItemId(issue); - response?.length > 0 && result.push(...response); - } - - return result; - - async function getProjectItemId(issueId) { - core.info(`Fetching project items for issue #${ issueId }...`); - - try { - const response = await github.graphql(` - query ($owner: String!, $repo: String!, $id: Int!) { - repository(owner: $owner, name: $repo) { - issue(number: $id) { - title, - projectItems(first: 10) { - nodes { - id, - } - } - } - } - } - `, - { - owner: context.repo.owner, - repo: context.repo.repo, - id: issueId, - } - ); - - const { repository: { issue: { projectItems: { nodes: projectItems } } } } = response; - - if (projectItems.length === 0) { - core.info('No project items found.\n'); - return []; - } - - const ids = projectItems.map((item) => item.id); - core.info(`Found [ ${ ids.join(', ') } ].\n`); - return ids; - - } catch (error) { - if (error.status === 404) { - core.info('Nothing has found.\n'); - return []; - } - } - } - - - name: Updating field value of the project items - id: updating_items - uses: actions/github-script@v6 - env: - ITEMS: ${{ steps.items.outputs.result }} - PROJECT_ID: ${{ steps.project_info.outputs.id }} - FIELD_ID: ${{ steps.project_info.outputs.field_id }} - FIELD_VALUE_ID: ${{ steps.project_info.outputs.field_value_id }} - with: - github-token: ${{ secrets.BOT_LABEL_ISSUE_TOKEN }} - script: | - const items = JSON.parse(process.env.ITEMS); - - if (items.length === 0) { - core.info('Nothing to update.'); - core.notice('No project items found for provided issues. Nothing to update.'); - return; - } - - for (const item of items) { - core.info(`Changing field value for item ${ item }...`); - await changeItemFieldValue(item); - core.info('Done.\n'); - } - - async function changeItemFieldValue(itemId) { - return await github.graphql( - ` - mutation($input: UpdateProjectV2ItemFieldValueInput!) { - updateProjectV2ItemFieldValue(input: $input) { - clientMutationId - } - } - `, - { - input: { - projectId: process.env.PROJECT_ID, - fieldId: process.env.FIELD_ID, - itemId, - value: { - singleSelectOptionId: process.env.FIELD_VALUE_ID, - }, - }, - } - ); - }; - diff --git a/.github/workflows/upload-source-maps.yml b/.github/workflows/upload-source-maps.yml deleted file mode 100644 index 55b18067fe..0000000000 --- a/.github/workflows/upload-source-maps.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Upload source maps to Sentry -on: - workflow_call: - workflow_dispatch: - -env: - SENTRY_ORG: ${{ vars.SENTRY_ORG }} - SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} - -jobs: - build_and_upload: - name: Build app with source maps and upload to Sentry - runs-on: ubuntu-latest - if: ${{ github.ref_type == 'tag' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: 20.11.0 - cache: 'yarn' - - - name: Cache node_modules - uses: actions/cache@v4 - id: cache-node-modules - with: - path: | - node_modules - key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn --frozen-lockfile --ignore-optional - - - name: Make production build with source maps - run: yarn build - env: - NODE_ENV: production - - - name: Inject Sentry debug ID - run: yarn sentry-cli sourcemaps inject ./.next - - - name: Upload source maps to Sentry - run: yarn sentry-cli sourcemaps upload --release=${{ github.ref_name }} --url-prefix=~/_next/ --validate ./.next \ No newline at end of file