Skip to content

cd

cd #38

Workflow file for this run

name: cd
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_run:
workflows:
- ci
types:
- completed
branches:
- master
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: "0"
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
cache: true
- name: Setup Node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: |
webapp/package-lock.json
e2e-tests/package-lock.json
- name: Install webapp npm deps
env:
NODE_ENV: development
run: |
set -e
cd webapp
npm install --ignore-scripts --no-save --legacy-peer-deps
- name: Building Plugin Bundle
run: make dist CGO_ENABLED=0
- name: Generating Release Notes
run: |
set -e
printf "Supported Mattermost Server Versions: **$(cat plugin.json | jq .min_server_version -r)+** \n## Enhancements\n\n## Fixes\n" >> dist/release-notes.md
if [[ $(git tag -l | wc -l) -eq 1 ]]; then
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git rev-list --max-parents=0 HEAD) HEAD >> dist/release-notes.md
else
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD >> dist/release-notes.md
fi
- name: Pesist build artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: dist
path: |
dist/*.tar.gz
dist/release-notes.md
retention-days: 5 ## No need to keep CI builds more than 5 days
deploy-ci:
runs-on: ubuntu-22.04
if: ${{ github.ref_name == 'master' }}
needs:
- build
steps:
- name: cd/checkout-repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: cd/download-artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist
- name: cd/rename-artifacts
run: mv dist/*.tar.gz dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz
- name: cd/rename-artifacts
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }}
- name: cd/artifact-upload
run: |
aws s3 cp dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz s3://mattermost-plugins-ci/ci/ --acl public-read --cache-control no-cache
deploy-release:
runs-on: ubuntu-22.04
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs:
- build
steps:
- name: cd/checkout-repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: cd/download-artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist
- name: cd/rename-artifacts
run: |
mv dist/*.tar.gz dist/playbooks-${GITHUB_REF_NAME}.tar.gz
- name: cd/rename-artifacts
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }}
- name: cd/artifact-upload
run: |
aws s3 cp dist/playbooks-${GITHUB_REF_NAME}.tar.gz s3://mattermost-plugins-ci/release/ --acl public-read --cache-control no-cache
- uses: jnwng/github-app-installation-token-action@c54add4c02866dc41e106745ac6dcf5cdd6339e5
id: installationToken
with:
appId: 276366
installationId: 32621164
privateKey: ${{ secrets.UNIFIED_CI_PRIVATE_KEY }}
- name: cd/create-github-release
env:
GITHUB_TOKEN: ${{ steps.installationToken.outputs.token }}
run: |
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file dist/release-notes.md dist/*.tar.gz