Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 207 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -81,19 +85,215 @@ jobs:
run: make unittest
working-directory: ./cmd/tools/testwick

build:
# Build AMD64 image (fast native build)
build-amd64:
runs-on: ubuntu-24.04
needs:
- test
- lint
needs: [test, lint]
steps:
- name: ci/checkout-repo
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Log in to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build AMD64 image (temp tag)
run: |
docker buildx build \
--platform linux/amd64 \
. -f build/Dockerfile -t mattermost/mattermost-cloud:temp-${{ github.sha }}-amd64 \
--push
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}

# Build ARM64 image (fast native build)
build-arm64:
runs-on: ubuntu-24.04-arm
needs: [test, lint]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Log in to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build ARM64 image (temp tag)
run: |
docker buildx build \
--platform linux/arm64 \
. -f build/Dockerfile -t mattermost/mattermost-cloud:temp-${{ github.sha }}-arm64 \
--push
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}

# Create unified multi-arch manifest (clean tag)
create-manifest:
runs-on: ubuntu-24.04
needs: [build-amd64, build-arm64]
steps:
- name: Log in to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create unified multi-arch manifest
run: |
# Determine clean tag
if [ "${{ github.event_name }}" = "pull_request" ]; then
CLEAN_TAG="pr-${{ github.event.number }}"
elif [ "${{ github.ref }}" = "refs/heads/master" ]; then
CLEAN_TAG="latest"
else
CLEAN_TAG="${{ github.ref_name }}"
fi

# Create manifest from temp tags
docker manifest create mattermost/mattermost-cloud:${CLEAN_TAG} \
--amend mattermost/mattermost-cloud:temp-${{ github.sha }}-amd64 \
--amend mattermost/mattermost-cloud:temp-${{ github.sha }}-arm64

# Push the clean unified tag
docker manifest push mattermost/mattermost-cloud:${CLEAN_TAG}

echo "βœ… Clean unified multi-arch tag: mattermost/mattermost-cloud:${CLEAN_TAG}"

# Cleanup temp tags using Docker Hub API
echo "πŸ—‘οΈ Cleaning up temp tags from Docker Hub..."

# Delete temp tags using Docker Hub API
TEMP_AMD64_TAG="temp-${{ github.sha }}-amd64"
TEMP_ARM64_TAG="temp-${{ github.sha }}-arm64"

# Get Docker Hub API token
DOCKER_HUB_TOKEN=$(curl -s -X POST \
-H "Content-Type: application/json" \
-d '{"username": "${{ secrets.DOCKERHUB_USERNAME }}", "password": "${{ secrets.DOCKERHUB_CLEANUP_TOKEN }}"}' \
https://hub.docker.com/v2/users/login/ | jq -r .token)

# Delete AMD64 temp tag
curl -X DELETE \
-H "Authorization: JWT ${DOCKER_HUB_TOKEN}" \
"https://hub.docker.com/v2/repositories/mattermost/mattermost-cloud/tags/${TEMP_AMD64_TAG}/" \
&& echo "βœ… Deleted AMD64 temp tag" || echo "⚠️ AMD64 temp tag not found or already deleted"

# Delete ARM64 temp tag
curl -X DELETE \
-H "Authorization: JWT ${DOCKER_HUB_TOKEN}" \
"https://hub.docker.com/v2/repositories/mattermost/mattermost-cloud/tags/${TEMP_ARM64_TAG}/" \
&& echo "βœ… Deleted ARM64 temp tag" || echo "⚠️ ARM64 temp tag not found or already deleted"

echo "βœ… Temp tags cleaned up from Docker Hub"

# Build E2E AMD64 (native build, parallel with main builds)
build-e2e-amd64:
runs-on: ubuntu-24.04
needs: [test, lint]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Log in to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build E2E AMD64 image (temp tag)
run: |
docker buildx build \
--platform linux/amd64 \
. -f build/Dockerfile.e2e -t mattermost/mattermost-cloud-e2e:temp-${{ github.sha }}-amd64 \
--push
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}

# Build E2E ARM64 (native build on ARM runner, parallel with main builds)
build-e2e-arm64:
runs-on: ubuntu-24.04-arm
needs: [test, lint]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: ci/build-docker
- name: Log in to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build E2E ARM64 image (temp tag)
run: |
docker buildx build \
--platform linux/arm64 \
. -f build/Dockerfile.e2e -t mattermost/mattermost-cloud-e2e:temp-${{ github.sha }}-arm64 \
--push
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
uses: ./.github/actions/docker-build

# Create unified E2E multi-arch manifest
create-e2e-manifest:
runs-on: ubuntu-24.04
needs: [build-e2e-amd64, build-e2e-arm64]
steps:
- name: Log in to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create unified E2E multi-arch manifest
run: |
# Create manifest from temp tags
docker manifest create mattermost/mattermost-cloud-e2e:test \
--amend mattermost/mattermost-cloud-e2e:temp-${{ github.sha }}-amd64 \
--amend mattermost/mattermost-cloud-e2e:temp-${{ github.sha }}-arm64

# Push the clean unified tag
docker manifest push mattermost/mattermost-cloud-e2e:test

echo "βœ… Clean unified E2E multi-arch tag: mattermost/mattermost-cloud-e2e:test"

# Cleanup temp E2E tags using Docker Hub API
echo "πŸ—‘οΈ Cleaning up temp E2E tags from Docker Hub..."

# Delete temp E2E tags using Docker Hub API
TEMP_AMD64_TAG="temp-${{ github.sha }}-amd64"
TEMP_ARM64_TAG="temp-${{ github.sha }}-arm64"

# Get Docker Hub API token
DOCKER_HUB_TOKEN=$(curl -s -X POST \
-H "Content-Type: application/json" \
-d '{"username": "${{ secrets.DOCKERHUB_USERNAME }}", "password": "${{ secrets.DOCKERHUB_CLEANUP_TOKEN }}"}' \
https://hub.docker.com/v2/users/login/ | jq -r .token)

# Delete E2E AMD64 temp tag
curl -X DELETE \
-H "Authorization: JWT ${DOCKER_HUB_TOKEN}" \
"https://hub.docker.com/v2/repositories/mattermost/mattermost-cloud-e2e/tags/${TEMP_AMD64_TAG}/" \
&& echo "βœ… Deleted E2E AMD64 temp tag" || echo "⚠️ E2E AMD64 temp tag not found or already deleted"

# Delete E2E ARM64 temp tag
curl -X DELETE \
-H "Authorization: JWT ${DOCKER_HUB_TOKEN}" \
"https://hub.docker.com/v2/repositories/mattermost/mattermost-cloud-e2e/tags/${TEMP_ARM64_TAG}/" \
&& echo "βœ… Deleted E2E ARM64 temp tag" || echo "⚠️ E2E ARM64 temp tag not found or already deleted"

echo "βœ… Temp E2E tags cleaned up from Docker Hub"
81 changes: 72 additions & 9 deletions .github/workflows/notify-release.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,88 @@
name: notify-release

on:
release:
types: [published]

permissions:
contents: read

jobs:
notify:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3.4.0
- shell: bash
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Extract release information
id: release_info
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
REPO=$(echo $GITHUB_CONTEXT | jq -r '.repository')
TAGVERSION=$(echo $GITHUB_CONTEXT | jq -r '.event.release.tag_name')
TAGURL=$(echo $GITHUB_CONTEXT | jq -r '.event.release.html_url')
BODY=$(echo $GITHUB_CONTEXT | jq -r '.event.release.body' | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g')
# Extract release information safely
REPO=$(echo "$GITHUB_CONTEXT" | jq -r '.repository')
TAGVERSION=$(echo "$GITHUB_CONTEXT" | jq -r '.event.release.tag_name')
TAGURL=$(echo "$GITHUB_CONTEXT" | jq -r '.event.release.html_url')
BODY=$(echo "$GITHUB_CONTEXT" | jq -r '.event.release.body // ""')

# Clean and format the body text
BODY_CLEAN=$(echo "$BODY" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\r*\n/\\n/g')

# Set outputs
echo "repo=$REPO" >> $GITHUB_OUTPUT
echo "tag=$TAGVERSION" >> $GITHUB_OUTPUT
echo "url=$TAGURL" >> $GITHUB_OUTPUT
echo "body=$BODY_CLEAN" >> $GITHUB_OUTPUT

# Debug output
echo "Repository: $REPO"
echo "Tag: $TAGVERSION"
echo "URL: $TAGURL"
echo "Body length: ${#BODY_CLEAN}"

echo "{\"username\":\"Cloud Bot Notify\",\"icon_url\":\"https://mattermost.com/wp-content/uploads/2022/02/icon.png\",\"text\":\"# **New Release for $REPO** - Release [$TAGVERSION]($TAGURL)\n $BODY\"}" > mattermost.json
- name: Create notification payload
id: payload
shell: bash
run: |
# Create JSON payload with proper escaping
cat > mattermost.json << 'EOF'
{
"username": "Cloud Bot Notify",
"icon_url": "https://mattermost.com/wp-content/uploads/2022/02/icon.png",
"text": "# πŸš€ **New Release for ${{ steps.release_info.outputs.repo }}**\n\n**Release:** [${{ steps.release_info.outputs.tag }}](${{ steps.release_info.outputs.url }})\n\n**Release Notes:**\n${{ steps.release_info.outputs.body }}"
}
EOF

# Validate JSON
if ! jq empty mattermost.json 2>/dev/null; then
echo "❌ Invalid JSON generated"
cat mattermost.json
exit 1
fi

echo "βœ… Valid JSON payload created"
cat mattermost.json

- uses: mattermost/action-mattermost-notify@1.0.2
- name: Send notification to Mattermost
uses: mattermost/action-mattermost-notify@master
if: env.MATTERMOST_WEBHOOK_URL != ''
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
with:
payload_file_path: ./mattermost.json

- name: Fallback notification
if: failure()
uses: mattermost/action-mattermost-notify@master
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
with:
payload: |
{
"username": "Cloud Bot Notify",
"icon_url": "https://mattermost.com/wp-content/uploads/2022/02/icon.png",
"text": "# πŸš€ **New Release for ${{ steps.release_info.outputs.repo }}**\n\n**Release:** [${{ steps.release_info.outputs.tag }}](${{ steps.release_info.outputs.url }})\n\n_Note: Release notes could not be formatted properly_"
}
Loading
Loading