Skip to content

vaas-rust-ci

vaas-rust-ci #302

Workflow file for this run

name: vaas-rust-ci
on:
push:
branches:
- main
paths:
- "rust/**"
- ".github/workflows/ci-rust.yaml"
tags:
- "rs*"
pull_request:
branches:
- main
paths:
- "rust/**"
- ".github/workflows/ci-rust.yaml"
workflow_dispatch:
inputs:
environment:
type: choice
description: "Test environment"
options:
- production
- staging
default: "production"
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/rs')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }}
VAAS_URL: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/rs')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }}
TOKEN_URL: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/rs')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }}
VAAS_CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
VAAS_USER_NAME: ${{ secrets.VAAS_USER_NAME }}
VAAS_PASSWORD: ${{ (inputs.environment == 'production' || inputs.environment == null || startsWith(github.ref, 'refs/tags/rs')) && secrets.VAAS_PASSWORD || secrets.STAGING_VAAS_PASSWORD }}
jobs:
build-rust:
name: Build & Test Rust SDK
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v3
- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
working-directory: rust
- name: run tests
run: cargo test
working-directory: rust
- name: extract version
if: startsWith(github.ref, 'refs/tags/rs')
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/rs}" >> $GITHUB_ENV
echo $RELEASE_VERSION
- name: set version
if: startsWith(github.ref, 'refs/tags/rs')
run: |
sed -i "s/version = \"0.0.0\"/version = \"$RELEASE_VERSION\"/g" ./rust/Cargo.toml
- name: publish crates.io package
if: startsWith(github.ref, 'refs/tags/rs')
run: cargo publish --allow-dirty --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
working-directory: rust
- name: Microsoft Teams Notification
uses: skitionek/notify-microsoft-teams@master
if: failure()
with:
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }}
overwrite: "{title: `Failed workflow on for VaaS-SDK ${workflow}`, sections: [{activityTitle: 'build failed', activitySubtitle: `Failed workflow on for VaaS-SDK ${workflow}`, activityImage: 'https://adaptivecards.io/content/cats/3.png'}], themeColor: '#ff0000'}"