Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Merge pull request #21 from MGTheTrain/release/0.2.0 #12

Merge pull request #21 from MGTheTrain/release/0.2.0

Merge pull request #21 from MGTheTrain/release/0.2.0 #12

name: Create git tag, run scans and tests on Rust repos
on:
push:
branches:
- master
env:
ARM_SUBSCRIPTION_ID: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
ARM_TENANT_ID: '${{ secrets.ARM_TENANT_ID }}'
ARM_CLIENT_ID: '${{ secrets.ARM_CLIENT_ID }}'
ARM_CLIENT_SECRET: '${{ secrets.ARM_CLIENT_SECRET }}'
jobs:
set-gh-outputs:
name: Set Github Outputs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Set semantic_version
id: branch_check
run: |
semantic_version=$(cat version)
echo "semantic_version=$semantic_version" >> $GITHUB_OUTPUT
- name: Print Semantic version
run: echo "semantic_version for branch '${{ github.base_ref }}' is '${{ steps.branch_check.outputs.semantic_version }}'"
outputs:
semantic_version: ${{ steps.branch_check.outputs.semantic_version }}
# Test, scan, build and push Rust related repos or compiled binaries
ci-ct-job-for-rust-repos:
runs-on: ubuntu-latest
needs: [set-gh-outputs]
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Init
id: init
run: |
terraform init
# -backend-config="subscription_id=${{ inputs.AZ_SUBSCRIPTION_ID }}" \
# -backend-config="storage_account_name=${{ inputs.AZ_STORAGE_ACCOUNT_NAME }}" \
# -backend-config="resource_group_name=${{ inputs.AZ_RESOURCE_GROUP_NAME }}" \
# -backend-config="container_name=${{ inputs.AZ_STORAGE_ACCOUNT_CONTAINER_NAME }}" \
# -backend-config="key=azure-rg/terraform.tfstate"
working-directory: ./devops/terraform
- name: Terraform Apply
id: apply
run: terraform apply --auto-approve
continue-on-error: false
working-directory: ./devops/terraform
- name: Resolve terraform outputs
id: resolve_terraform_outputs
run: |
sudo apt-get install -y jq
cd ./devops/terraform
echo "azure_account_name=$(terraform output -json storage_account_name_list | jq -r --argjson index 0 '.[$index]')" >> $GITHUB_OUTPUT
echo "azure_access_key=$(terraform output -json storage_account_primary_access_key_list | jq -r --argjson index 0 '.[$index]')" >> $GITHUB_OUTPUT
echo "azure_container_name=$(terraform output -json storage_account_container_name_list | jq -r --argjson index 0 '.[$index]')" >> $GITHUB_OUTPUT
cd -
working-directory: ./
- name: Test Rust repository
uses: MGTheTrain/public-github-actions/.github/actions/test-rust-repository@main
with:
WORKING_DIRECTORY: ./
env:
AZURE_ACCOUNT_NAME: ${{ steps.resolve_terraform_outputs.outputs.azure_account_name }}
AZURE_ACCESS_KEY: ${{ steps.resolve_terraform_outputs.outputs.azure_access_key }}
AZURE_CONTAINER_NAME: ${{ steps.resolve_terraform_outputs.outputs.azure_container_name }}
- name: Sleep for 16 seconds
run: sleep 16
- name: Terraform Destroy
id: destroy
run: terraform destroy --auto-approve
continue-on-error: false
working-directory: ./devops/terraform
create-git-tags-from-version-file-job:
runs-on: ubuntu-latest
needs: [set-gh-outputs]
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create git tag from version file
uses: MGTheTrain/public-github-actions/.github/actions/create-git-tag-from-version-file@main
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }}