This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of Migration from CircleCI to GitHubActions Ticket: https://mattermost.atlassian.net/browse/CLD-4811 Signed-off-by: Akis Maziotis <akis.maziotis@mattermost.com>
- Loading branch information
1 parent
7f5e914
commit 6b5d150
Showing
1 changed file
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
name: cd | ||
on: | ||
workflow_run: | ||
workflows: | ||
- ci | ||
types: | ||
- completed | ||
branches-ignore: | ||
- master | ||
- release-** | ||
- cloud-** | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
prepare-docker-build: | ||
runs-on: ubuntu-22.04 | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
env: | ||
REPO_NAME: ${{ github.event.repository.name }} | ||
steps: | ||
- name: ci/checkout-repo | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
# We need to sanitize the branch name before using it | ||
- name: ci/sanitize-branch-name | ||
id: branch | ||
uses: transferwise/sanitize-branch-name@b10b4d524ac5a7b645b43a3527db3a6cca017b9d # v1 | ||
# Search for the string "pull" and replace it with "PR" in branch-name | ||
- name: ci/sanitize-branch-name-replace-pull-with-PR- | ||
run: echo "BRANCH_NAME=$(echo ${{ steps.branch.outputs.sanitized-branch-name }} | sed 's/^pull\//PR-/g')" >> $GITHUB_ENV | ||
- name: ci/artifacts-downloads | ||
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b # v3.0.2 | ||
with: | ||
name: webapp-artifact | ||
- name: ci/Download-server-bundle | ||
run: | | ||
curl -f -o server.tar.gz https://pr-builds.mattermost.com/mattermost-server/$BRANCH_NAME/mattermost-enterprise-linux-amd64.tar.gz || true | ||
if [[ -f server.tar.gz ]]; then | ||
echo "Downloaded server bundle for $BRANCH_NAME branch from pr-builds.mattermost.com" | ||
else | ||
curl -f -o server.tar.gz https://s3.amazonaws.com/releases.mattermost.com/gitlab/bundle/master/mattermost-enterprise-linux-amd64.tar.gz | ||
echo "Downloaded server bundle for master from releases.mattermost.com" | ||
fi | ||
tar xf server.tar.gz | ||
- name: ci/Replace-web-app | ||
run: | | ||
mv mattermost/client client-original | ||
tar xf mattermost-webapp.tar.gz | ||
mv client mattermost/client | ||
- name: ci/Re-add-products | ||
run: | | ||
mv client-original/products mattermost/client/products | ||
- name: ci/Repackage server bundle | ||
run: | | ||
tar -zcf mattermost-enterprise-linux-amd64.tar.gz mattermost/ | ||
- name: ci/persist-artifact | ||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | ||
with: | ||
name: mattermost-enterprise-linux-artifact | ||
path: mattermost-enterprise-linux-amd64.tar.gz | ||
- name: ci/aws-configure | ||
uses: aws-actions/configure-aws-credentials@07c2f971bac433df982ccc261983ae443861db49 # v1-node16 | ||
with: | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
- name: ci/artifact-upload | ||
run: | | ||
aws s3 cp mattermost-enterprise-linux-amd64.tar.gz s3://${{secrets.AWS_S3_BUCKET_PRS}}/$REPO_NAME/commit/${{ github.sha }}/ --cache-control no-cache | ||
build-docker: | ||
runs-on: ubuntu-22.04 | ||
needs: prepare-docker-build | ||
steps: | ||
- name: cd/Set environment variables | ||
id: vars | ||
run: | | ||
echo "TAG=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | ||
echo "REPO_NAME=${{github.event.repository.name}}" >> $GITHUB_ENV | ||
- name: cd/Login to Docker Hub | ||
uses: docker/login-action@3da7dc6e2b31f99ef2cb9fb4c50fb0971e0d0139 # v2.1.0 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: cd/Setup Docker Buildx | ||
uses: docker/setup-buildx-action@11e8a2e2910826a92412015c515187a2d6750279 # v2.4 | ||
- name: cd/docker-build-push | ||
env: | ||
DOCKER_CLI_EXPERIMENTAL: enabled | ||
run: | | ||
wget https://raw.githubusercontent.com/mattermost/mattermost-server/master/build/Dockerfile | ||
wget https://raw.githubusercontent.com/mattermost/mattermost-server/master/build/entrypoint.sh | ||
chmod +x entrypoint.sh | ||
export MM_PACKAGE=https://pr-builds.mattermost.com/$REPO_NAME/commit/${{ github.sha }}/mattermost-enterprise-linux-amd64.tar.gz | ||
docker buildx build --push --build-arg MM_PACKAGE=$MM_PACKAGE -t mattermost/mm-ee-test:${TAG} . | ||