From ee23f6dc6b864bf9ea4c51de799048b6c9927f5d Mon Sep 17 00:00:00 2001 From: Antonis Stamatiou Date: Wed, 26 Apr 2023 13:15:04 +0300 Subject: [PATCH] fix: Fixed wrong commit sha reference from incoming webhook --- .github/workflows/artifacts.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 35829f9f04..1886775a8e 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -25,15 +25,14 @@ jobs: workflow_conclusion: success name: server-dist-artifact path: server/dist - # DISABLING THIS UNTIL WE FIGURE OUT IF WE NEED IT - # Get Branch name from calling workflow - # Search for the string "pull" and replace it with "PR" in branch-name - # - name: cd/Get branch name - # run: echo "BRANCH_NAME=$(echo ${{ github.event.workflow_run.head_branch }} | sed 's/^pull\//PR-/g')" >> $GITHUB_ENV - name: cd/Upload artifacts to S3 + env: + BRANCH_NAME: ${{ github.event.workflow_run.head_branch }} + REPO_NAME: ${{ github.event.repository.name }} + COMMIT_SHA: ${{ github.event.workflow_run.head_sha }} run: | - aws s3 cp server/dist/ s3://pr-builds.mattermost.com/${{ github.event.repository.name }}/${{ github.event.workflow_run.head_branch }}/ --acl public-read --cache-control "no-cache" --recursive --no-progress - aws s3 cp server/dist/ s3://pr-builds.mattermost.com/${{ github.event.repository.name }}/commit/${{ github.sha }}/ --acl public-read --cache-control "no-cache" --recursive --no-progress + aws s3 cp server/dist/ s3://pr-builds.mattermost.com/$REPO_NAME/$BRANCH_NAME/ --acl public-read --cache-control "no-cache" --recursive --no-progress + aws s3 cp server/dist/ s3://pr-builds.mattermost.com/$REPO_NAME/commit/$COMMIT_SHA/ --acl public-read --cache-control "no-cache" --recursive --no-progress build-docker: name: cd/Build and push docker image @@ -59,11 +58,13 @@ jobs: - name: cd/Docker build and push env: DOCKER_CLI_EXPERIMENTAL: enabled + REPO_NAME: ${{ github.event.repository.name }} + COMMIT_SHA: ${{ github.event.workflow_run.head_sha }} run: | - export TAG=$(echo "${{ github.event.pull_request.head.sha || github.sha }}" | cut -c1-7) + export TAG=$(echo "${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha }}" | cut -c1-7) cd server/build export DOCKER_CLI_EXPERIMENTAL=enabled - export MM_PACKAGE=https://pr-builds.mattermost.com/${{ github.event.repository.name }}/commit/${{ github.sha }}/mattermost-team-linux-amd64.tar.gz + export MM_PACKAGE=https://pr-builds.mattermost.com/$REPO_NAME/commit/$COMMIT_SHA/mattermost-team-linux-amd64.tar.gz docker buildx build --push --build-arg MM_PACKAGE=$MM_PACKAGE -t mattermostdevelopment/mm-te-test:${TAG} . # Temporary uploading also to mattermost/mm-te-test:${TAG} except mattermostdevelopment/mm-te-test:${TAG} @@ -71,6 +72,9 @@ jobs: build-docker-temp: name: cd/Build and push docker image needs: upload-s3 + env: + REPO_NAME: ${{ github.event.repository.name }} + runs-on: ubuntu-22.04 if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' steps: @@ -92,11 +96,13 @@ jobs: - name: cd/Docker build and push env: DOCKER_CLI_EXPERIMENTAL: enabled + REPO_NAME: ${{ github.event.repository.name }} + COMMIT_SHA: ${{ github.event.workflow_run.head_sha }} run: | - export TAG=$(echo "${{ github.event.pull_request.head.sha || github.sha }}" | cut -c1-7) + export TAG=$(echo "${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha }}" | cut -c1-7) cd server/build export DOCKER_CLI_EXPERIMENTAL=enabled - export MM_PACKAGE=https://pr-builds.mattermost.com/${{ github.event.repository.name }}/commit/${{ github.sha }}/mattermost-team-linux-amd64.tar.gz + export MM_PACKAGE=https://pr-builds.mattermost.com/$REPO_NAME/commit/$COMMIT_SHA/mattermost-team-linux-amd64.tar.gz docker buildx build --push --build-arg MM_PACKAGE=$MM_PACKAGE -t mattermost/mm-te-test:${TAG} . sentry: