Skip to content

Deploy to by @sebastian-quintero from feature/auto-release-workflow #105

Deploy to by @sebastian-quintero from feature/auto-release-workflow

Deploy to by @sebastian-quintero from feature/auto-release-workflow #105

Workflow file for this run

name: release
run-name: Deploy to ${{ inputs.TARGET_ENVIRONMENT }} by @${{ github.actor }} from ${{ github.ref_name }}
on:
workflow_dispatch:
inputs:
TARGET_ENVIRONMENT:
type: choice
description: "The environment to release to (dev, staging, prod)"
default: "dev"
required: true
options:
- dev
- staging
- prod
APPS:
type: string
description: "The apps to release, comma separated. E. g.: `go-highs-knapsack,java-ortools-knapsack`"
required: true
push:
branches:
- develop
- feature/auto-release-workflow
permissions:
contents: read
packages: read
jobs:
update_apps:
runs-on: ubuntu-latest
environment: ${{ inputs.TARGET_ENVIRONMENT || 'dev' }} # TODO: change to prod once detecting changes works
env:
BUCKET: ${{ secrets.S3_BUCKET }}
FOLDER: ${{ secrets.S3_FOLDER }}
MANIFEST: ${{ secrets.S3_MANIFEST }}
ROLE: ${{ secrets.AWS_DEVTOOLS_ROLE }}
REGION: ${{ secrets.AWS_REGION }}
GH_TOKEN: ${{ github.token }}
API_ENDPOINT: ${{ secrets.API_ENDPOINT }}
CONSOLE_URL: ${{ secrets.CONSOLE_URL }}
MARKETPLACE_API_KEY: ${{ secrets.MARKETPLACE_API_KEY }}
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
GO_VERSION: ""
PYTHON_VERSION: ""
APPS: ""
APP_NAMES: ""
FILTERS: ""
permissions:
id-token: write
contents: write
steps:
- name: Configure git with the bot credentials
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.NEXTMVBOT_SSH_KEY }}"
echo "${{ secrets.NEXTMVBOT_SIGNING_KEY }}" > ~/.ssh/signing.key
chmod 600 ~/.ssh/signing.key
git config --global user.name "nextmv-bot"
git config --global user.email "tech+gh-nextmv-bot@nextmv.io"
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/signing.key
git clone git@github.com:nextmv-io/community-apps.git
cd community-apps
git fetch --all
git checkout ${{ github.ref_name }}
git pull
- name: determine if apps are provided through inputs or we need filters
run: |
export APPS="${{ inputs.APPS }}"
if [ $APPS != '' ]; then
echo "These are the apps to release => $APPS"
echo "APPS=${APPS}" >> $GITHUB_ENV
exit 0
fi
APP_NAMES_ARRAY=$(yq '.apps[].name' workflow-configuration.yml)
APP_NAMES=$(echo ${APP_NAMES_ARRAY[@]} | tr '\n' ' ')
echo "Successfuly obtained APP NAMES => $APP_NAMES"
echo "APP_NAMES=${APP_NAMES}" >> $GITHUB_ENV
echo "Successfully set APP_NAMES in the environment"
export FILTERS = ""
for app in $(echo "$APP_NAMES"); do
FILTERS="${FILTERS}${app}:\n - '${app}/**'\n"
done
echo "FILTERS=${FILTERS}" >> $GITHUB_ENV
working-directory: ./community-apps/.nextmv
- name: Filter changed directories
id: filter
if: ${{ env.FILTERS != '' }}
uses: dorny/paths-filter@v2
with:
filters: ${{ env.FILTERS }}
- name: Create comma-separated string of changed paths
id: changed_paths
if: ${{ env.FILTERS != '' }}
run: |
export APPS=""
OUTPUTS=$(echo '${{ toJson(steps.filter.outputs) }}' | jq .)
for app in $(echo "${{ env.APP_NAMES }}"); do
if [ $(echo $OUTPUTS | jq -r --arg app "$app" '.[$app]') == "true" ]; then
APPS="${APPS}${app},"
fi
done
# Remove trailing comma
APPS="${APPS%,}"
echo "These are the apps to release => $APPS"
echo "APPS=${APPS}" >> $GITHUB_ENV
- name: set Python version
run: |
export PYTHON_VERSION=$(yq '.language-support.python.version' workflow-configuration.yml)
echo "This is the Python version => $PYTHON_VERSION"
echo "PYTHON_VERSION=${PYTHON_VERSION}" >> $GITHUB_ENV
working-directory: ./community-apps/.nextmv
- name: set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: set go version
run: |
export GO_VERSION=$(yq '.language-support.go.version' workflow-configuration.yml)
echo "This is the Go version => $GO_VERSION"
echo "GO_VERSION=${GO_VERSION}" >> $GITHUB_ENV
working-directory: ./community-apps/.nextmv
- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install zig
run: |
SIGNATURE="2d00e789fec4f71790a6e7bf83ff91d564943c5ee843c5fd966efc474b423047 zig-linux-x86_64-0.11.0.tar.xz"
curl -sSfL https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz -o zig-linux-x86_64-0.11.0.tar.xz
echo $SIGNATURE | sha256sum -c
tar -xf zig-linux-x86_64-0.11.0.tar.xz
sudo ln -s $PWD/zig-linux-x86_64-0.11.0/zig /usr/local/bin/zig
zig version
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
working-directory: ./community-apps/.nextmv/release
- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.ROLE }}
aws-region: ${{ env.REGION }}
role-duration-seconds: 1200
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
cache: "maven"
- name: Install Nextmv CLI
run: |
export NEXTMV_API_KEY=$MARKETPLACE_API_KEY
export NEXTMV_BASE_URL=https://$API_ENDPOINT
curl -sS "https://$CONSOLE_URL/install-cli.txt" | bash -
- name: Set up Nextmv CLI
run: |
export PATH=$PATH:~/.nextmv # Make CLI available in non-interactive shell
nextmv configure \
--api-key $MARKETPLACE_API_KEY \
-e $API_ENDPOINT
nextmv activate
nextmv sdk install
# - name: Release the apps
# run: |
# export PATH=$PATH:~/.nextmv # Make CLI available in non-interactive shell
# python main.py \
# --apps "${{ env.APPS }}" \
# --bucket "${{ env.BUCKET }}" \
# --folder "${{ env.FOLDER }}" \
# --manifest "${{ env.MANIFEST }}"
# working-directory: ./community-apps/.nextmv/release