Skip to content

Commit

Permalink
Add automatic deployment and a master link. (#265)
Browse files Browse the repository at this point in the history
* ci: Add continuous deployment workflow for Mattermost plugin

* ci: Enable deployment workflow on test-deploy branch for testing

* feat: Support multiple tokens for Mattermost server deployments

* feat: Add force flag for plugin deployment in CI and Makefile

* unessisary

* setup to test

* feat: Add latest-master release creation and download badge

* Enable test branch

* Remove test branch

* no need for commit message
  • Loading branch information
crspeller authored Dec 12, 2024
1 parent 654e1e7 commit c1a0c0b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
59 changes: 58 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:

permissions:
contents: read
contents: write

jobs:
e2e:
Expand Down Expand Up @@ -43,3 +43,60 @@ jobs:
golangci-lint-version: "v1.54.2"
golang-version: "1.21"
secrets: inherit

deploy:
needs: [plugin-ci, e2e]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build plugin
run: make dist

- name: Update latest-master release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PLUGIN_FILE=$(ls dist/*.tar.gz)
# Get the commit message and hash
COMMIT_MSG=$(git log -1 --pretty=%B)
COMMIT_HASH=$(git rev-parse --short HEAD)
# Delete the old release if it exists
gh release delete latest-master --yes || true
# Delete the old tag if it exists
git tag -d latest-master || true
git push origin :refs/tags/latest-master || true
# Create new tag and release
git tag latest-master
git push origin latest-master
gh release create latest-master \
--title "Latest Master Build" \
--notes "Latest build from master branch - ${COMMIT_HASH}" \
--prerelease \
$PLUGIN_FILE
- name: Deploy to Mattermost instances
env:
MM_SERVERS_CONFIG: ${{ secrets.MM_SERVERS_CONFIG }}
run: |
PLUGIN_FILE=$(ls dist/*.tar.gz)
echo "Found plugin bundle: $PLUGIN_FILE"
echo "$MM_SERVERS_CONFIG" | jq -c '.[]' | while read -r server; do
url=$(echo "$server" | jq -r '.url')
token=$(echo "$server" | jq -r '.token')
echo "Deploying to $url"
curl -H "Authorization: Bearer $token" \
-X POST \
-F "plugin=@$PLUGIN_FILE" \
-F "force=true" \
"$url/api/v4/plugins"
done
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mattermost Copilot Plugin
# Mattermost Copilot Plugin [![Download Latest Master Build](https://img.shields.io/badge/Download-Latest%20Master%20Build-blue)](https://github.com/mattermost/mattermost-plugin-ai/releases/tag/latest-master)

> Mattermost plugin for local and third-party LLMs
Expand Down

0 comments on commit c1a0c0b

Please sign in to comment.