Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic deployment and a master link. #265

Merged
merged 10 commits into from
Dec 12, 2024
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
Loading