mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fix - Run artifacts workflow only for monorepo branches (#25279)
* Run artifacts jobs conditionally, add test change --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
db238a205c
commit
5d1cb1b931
31
.github/workflows/server-ci-artifacts.yml
vendored
31
.github/workflows/server-ci-artifacts.yml
vendored
@ -24,10 +24,29 @@ jobs:
|
|||||||
description: Artifacts upload and build for mattermost team platform
|
description: Artifacts upload and build for mattermost team platform
|
||||||
status: pending
|
status: pending
|
||||||
|
|
||||||
|
## We need to determine if we're trying to merge to a pre-8.x branch, but 'workflow_run' doesn't give us information about the target branch.
|
||||||
|
## But we can determine this also by checking if we're in the monorepo directory structure or not.
|
||||||
|
determine-if-monorepo:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
needs:
|
||||||
|
- update-initial-status
|
||||||
|
outputs:
|
||||||
|
is_monorepo: "${{ steps['determine-if-monorepo'].outputs.is_monorepo }}"
|
||||||
|
steps:
|
||||||
|
- name: cd/checkout-mattermost
|
||||||
|
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
||||||
|
- name: cd/determine-if-monorepo
|
||||||
|
id: determine-if-monorepo
|
||||||
|
run: |
|
||||||
|
# Assert that the 'server' directory doesn't exist. But if it does, set 'is_monorepo=true'
|
||||||
|
IS_MONOREPO=$([ ! -d server ] || echo -n 'true')
|
||||||
|
echo "is_monorepo=$IS_MONOREPO" | tee --append "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
upload-artifacts:
|
upload-artifacts:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs:
|
needs:
|
||||||
- update-initial-status
|
- update-initial-status
|
||||||
|
- determine-if-monorepo
|
||||||
steps:
|
steps:
|
||||||
- name: cd/configure-aws-credentials
|
- name: cd/configure-aws-credentials
|
||||||
uses: aws-actions/configure-aws-credentials@04b98b3f9e85f563fb061be8751a0352327246b0 #v3.0.1
|
uses: aws-actions/configure-aws-credentials@04b98b3f9e85f563fb061be8751a0352327246b0 #v3.0.1
|
||||||
@ -35,6 +54,7 @@ jobs:
|
|||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
aws-access-key-id: ${{ secrets.PR_BUILDS_BUCKET_AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ secrets.PR_BUILDS_BUCKET_AWS_ACCESS_KEY_ID }}
|
||||||
aws-secret-access-key: ${{ secrets.PR_BUILDS_BUCKET_AWS_SECRET_ACCESS_KEY }}
|
aws-secret-access-key: ${{ secrets.PR_BUILDS_BUCKET_AWS_SECRET_ACCESS_KEY }}
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
- name: cd/download-artifacts-from-PR-workflow
|
- name: cd/download-artifacts-from-PR-workflow
|
||||||
uses: dawidd6/action-download-artifact@0c49384d39ceb023b8040f480a25596fd6cf441b # v2.26.0
|
uses: dawidd6/action-download-artifact@0c49384d39ceb023b8040f480a25596fd6cf441b # v2.26.0
|
||||||
@ -44,6 +64,7 @@ jobs:
|
|||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
name: server-dist-artifact
|
name: server-dist-artifact
|
||||||
path: server/dist
|
path: server/dist
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
- name: cd/generate-packages-file-list
|
- name: cd/generate-packages-file-list
|
||||||
working-directory: ./server/dist
|
working-directory: ./server/dist
|
||||||
@ -51,9 +72,11 @@ jobs:
|
|||||||
echo "PACKAGES_FILE_LIST<<EOF" >> "${GITHUB_ENV}"
|
echo "PACKAGES_FILE_LIST<<EOF" >> "${GITHUB_ENV}"
|
||||||
ls | grep -E "*.(tar.gz|zip)$" >> "${GITHUB_ENV}"
|
ls | grep -E "*.(tar.gz|zip)$" >> "${GITHUB_ENV}"
|
||||||
echo "EOF" >> "${GITHUB_ENV}"
|
echo "EOF" >> "${GITHUB_ENV}"
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
- name: cd/upload-artifacts-to-s3
|
- name: cd/upload-artifacts-to-s3
|
||||||
run: aws s3 sync server/dist/ s3://pr-builds.mattermost.com/mattermost/commit/${{ github.event.workflow_run.head_sha }}/ --cache-control no-cache --no-progress --acl public-read
|
run: aws s3 sync server/dist/ s3://pr-builds.mattermost.com/mattermost/commit/${{ github.event.workflow_run.head_sha }}/ --cache-control no-cache --no-progress --acl public-read
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
- name: cd/generate-summary
|
- name: cd/generate-summary
|
||||||
run: |
|
run: |
|
||||||
@ -66,17 +89,20 @@ jobs:
|
|||||||
do
|
do
|
||||||
echo "|[${package}](https://s3.amazonaws.com/pr-builds.mattermost.com/mattermost/commit/${{ github.event.workflow_run.head_sha }}/${package})|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|[${package}](https://s3.amazonaws.com/pr-builds.mattermost.com/mattermost/commit/${{ github.event.workflow_run.head_sha }}/${package})|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
done
|
done
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
build-docker:
|
build-docker:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs:
|
needs:
|
||||||
- upload-artifacts
|
- upload-artifacts
|
||||||
|
- determine-if-monorepo
|
||||||
steps:
|
steps:
|
||||||
- name: cd/docker-login
|
- name: cd/docker-login
|
||||||
uses: docker/login-action@3da7dc6e2b31f99ef2cb9fb4c50fb0971e0d0139 # v2.1.0
|
uses: docker/login-action@3da7dc6e2b31f99ef2cb9fb4c50fb0971e0d0139 # v2.1.0
|
||||||
with:
|
with:
|
||||||
username: mattermostdev
|
username: mattermostdev
|
||||||
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
- name: cd/download-artifacts-from-PR-workflow
|
- name: cd/download-artifacts-from-PR-workflow
|
||||||
uses: dawidd6/action-download-artifact@0c49384d39ceb023b8040f480a25596fd6cf441b # v2.26.0
|
uses: dawidd6/action-download-artifact@0c49384d39ceb023b8040f480a25596fd6cf441b # v2.26.0
|
||||||
@ -86,9 +112,11 @@ jobs:
|
|||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
name: server-build-artifact
|
name: server-build-artifact
|
||||||
path: server/build/
|
path: server/build/
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
- name: cd/setup-docker-buildx
|
- name: cd/setup-docker-buildx
|
||||||
uses: docker/setup-buildx-action@11e8a2e2910826a92412015c515187a2d6750279 # v2.4
|
uses: docker/setup-buildx-action@11e8a2e2910826a92412015c515187a2d6750279 # v2.4
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
- name: cd/docker-build-and-push
|
- name: cd/docker-build-and-push
|
||||||
env:
|
env:
|
||||||
@ -97,12 +125,14 @@ jobs:
|
|||||||
export TAG=$(echo "${{ github.event.workflow_run.head_sha }}" | cut -c1-7)
|
export TAG=$(echo "${{ github.event.workflow_run.head_sha }}" | cut -c1-7)
|
||||||
cd server/build
|
cd server/build
|
||||||
docker buildx build --no-cache --platform linux/amd64 --push --build-arg MM_PACKAGE=$MM_PACKAGE -t mattermostdevelopment/mm-te-test:${TAG} .
|
docker buildx build --no-cache --platform linux/amd64 --push --build-arg MM_PACKAGE=$MM_PACKAGE -t mattermostdevelopment/mm-te-test:${TAG} .
|
||||||
|
if: needs['determine-if-monorepo'].outputs.is_monorepo == 'true'
|
||||||
|
|
||||||
update-failure-final-status:
|
update-failure-final-status:
|
||||||
if: failure() || cancelled()
|
if: failure() || cancelled()
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs:
|
needs:
|
||||||
- build-docker
|
- build-docker
|
||||||
|
- determine-if-monorepo
|
||||||
steps:
|
steps:
|
||||||
- uses: mattermost/actions/delivery/update-commit-status@a74f6d87f847326c04d326bf1908da40cb9b3556
|
- uses: mattermost/actions/delivery/update-commit-status@a74f6d87f847326c04d326bf1908da40cb9b3556
|
||||||
env:
|
env:
|
||||||
@ -119,6 +149,7 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
needs:
|
needs:
|
||||||
- build-docker
|
- build-docker
|
||||||
|
- determine-if-monorepo
|
||||||
steps:
|
steps:
|
||||||
- uses: mattermost/actions/delivery/update-commit-status@a74f6d87f847326c04d326bf1908da40cb9b3556
|
- uses: mattermost/actions/delivery/update-commit-status@a74f6d87f847326c04d326bf1908da40cb9b3556
|
||||||
env:
|
env:
|
||||||
|
Loading…
Reference in New Issue
Block a user