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
48 changes: 48 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI/CD

on:
pull_request:
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'

env:
MATTERMOST_CHANNEL: publication
MATTERMOST_HOOK_URL: ${{ secrets.MATTERMOST_HOOK_URL }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}

jobs:
build:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint
run: yarn lint
- name: Build
run: yarn build
- name: Set SSH git push
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- name: Publish
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
run: |
DEPLOY_BRANCH=build yarn deploy
BUILD_SHA=$(git rev-parse build)
BUILD_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/$BUILD_SHA.tar.gz
if [[ $GITHUB_REF == refs/tags/* ]]; then
yarn cozyPublish --yes --build-url $BUILD_URL --postpublish mattermost
else
yarn cozyPublish --yes --build-url $BUILD_URL
fi
12 changes: 1 addition & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
konnector-dev-config.json*
fixtures/*
data/*
.env

# NPM
node_modules/
Expand Down Expand Up @@ -32,14 +33,3 @@ desktop.ini
# Default
# /!\ KEEP THIS SECTION THE LAST ONE
!.gitkeep

# Yarn
.yarn/
.yarnrc.yml
yarn.lock

# Husky
.husky/

# ESLint
eslint.config.js
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.18.3
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

52 changes: 0 additions & 52 deletions bin/generate_travis_deploy_key

This file was deleted.

69 changes: 0 additions & 69 deletions bin/generate_travis_deploy_key.ps1

This file was deleted.

48 changes: 48 additions & 0 deletions bin/init_github_action
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

set -e

# .env file sample
# MATTERMOST_HOOK_URL=https://***
# REGISTRY_TOKEN="***"

if [ ! -f ".env" ]; then
echo "Error: .env file is missing"
echo "Please create a .env file with the following structure:"
echo "MATTERMOST_HOOK_URL=https://your-mattermost-hook-url"
echo "REGISTRY_TOKEN=your-registry-token"
exit 1
fi

# Check if required environment variables are present in .env
if ! grep -q "^MATTERMOST_HOOK_URL=" .env || ! grep -q "^REGISTRY_TOKEN=" .env; then
echo "Error: MATTERMOST_HOOK_URL and/or REGISTRY_TOKEN missing from .env file"
exit 1
fi

# Source the .env file to get variables
source .env

# Check if variables are empty
if [ -z "$MATTERMOST_HOOK_URL" ] || [ -z "$REGISTRY_TOKEN" ]; then
echo "Error: MATTERMOST_HOOK_URL and/or REGISTRY_TOKEN cannot be empty in .env file"
exit 1
fi

# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo "Error: GitHub CLI (gh) is not installed"
echo "Please install it from: https://cli.github.com/"
exit 1
fi

# generate a new private and public key
ssh-keygen -t rsa -b 4096 -f github_deploy_key -N '' -C $url -q 1>/dev/null

gh repo deploy-key add --allow-write --title "github_deploy_key" ./github_deploy_key.pub
gh secret set DEPLOY_KEY < github_deploy_key
gh secret set -f .env

# cleaning
rm github_deploy_key
rm github_deploy_key.pub
Binary file removed github_deploy_key.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"lint": "eslint --fix .",
"deploy": "git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build} --repo=${DEPLOY_REPOSITORY:-$npm_package_repository_url}",
"cozyPublish": "cozy-app-publish --token $REGISTRY_TOKEN --build-commit $(git rev-parse ${DEPLOY_BRANCH:-build})",
"travisDeployKey": "./bin/generate_travis_deploy_key"
"initGithubAction": "./bin/init_github_action"
},
"dependencies": {
"@cozy/minilog": "1.0.0",
Expand Down