Skip to content

Commit

Permalink
πŸ”€ Merge pull request #369 from COS301-SE-2024/dev/feat/devops
Browse files Browse the repository at this point in the history
✨ Added a full pipeline and documentation for awards
  • Loading branch information
ChuufMaster authored Oct 17, 2024
2 parents fc9d397 + a886fda commit 4c73956
Show file tree
Hide file tree
Showing 70 changed files with 4,041 additions and 1,973 deletions.
55 changes: 55 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Add 'root' label to any root file changes
# Quotation marks are required for the leading asterisk
root:
- changed-files:
- any-glob-to-any-file: '*'

# Add 'AnyChange' label to any changes within the entire repository
AnyChange:
- changed-files:
- any-glob-to-any-file: '**'

DevOps:
- changed-files:
- any-glob-to-any-file:
- '.github/*'
# Add 'Documentation' label to any file changes within 'docs' or 'guides' folders
Documentation:
- changed-files:
- any-glob-to-any-file:
- doc/*
- '**/*.md'
- head-branch: ['^doc', 'doc']

Dotnet:
- changed-files:
- any-glob-to-any-file:
- dotnet/*

BirdApi:
- changed-files:
- any-glob-to-any-file:
- dotnet/BirdApi/*

UserApi:
- changed-files:
- any-glob-to-any-file:
- dotnet/BirdApi/*

flutter:
- changed-files:
- any-glob-to-any-file:
- beakpeek/*

# Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name
feature:
- head-branch: ['^dev/feat', 'feat']

fix:
- head-branch: ['^dev/fix', 'fix']

test:
- head-branch: ['^dev/test', 'test']

release:
- base-branch: 'main'
56 changes: 40 additions & 16 deletions .github/workflows/deploy_dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Deploy BeakPeekBirdApi
name: πŸš€ Deploy Dotnet BirdApi

env:
# DOTNET_ROOT: ./dotnet/BeakPeekApi/
Expand All @@ -18,29 +15,42 @@ on:
- 'beakpeek/**'
- 'dotnet/UserApi/**'
workflow_dispatch:
workflow_call:

jobs:
test:
test_dotnet:
name: πŸ§ͺ Test dotnet BirdApi
uses: ./.github/workflows/dotnet.yml
secrets: inherit

build:
name: πŸ›οΈ Build BirdApi
runs-on: ubuntu-latest
# needs: test

needs: [ test_dotnet ]
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/birdapi/packages
outputs:
artifact_url: ${{ steps.artifact-upload-step.outputs.artifact-url}}
steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
include-prerelease: true
cache: true
cache-dependency-path: ./dotnet/BirdApi/BeakPeekApi/packages.lock.json

- name: Get App Setting
run: |
cd ./dotnet/BirdApi/BeakPeekApi
cp ../../../appsettings.json .
- name: Restore Dependencies
run: |
cd ./dotnet/BirdApi/BeakPeekApi
dotnet restore --locked-mode
- name: Build with dotnet
run: dotnet build --configuration Release ./dotnet/BirdApi/BeakPeekApi/BeakPeekApi.csproj

Expand All @@ -55,14 +65,16 @@ jobs:
cp -r ./res/species_list/* ${{env.DOTNET_ROOT}}/BeakPeekApi/res/species_list/
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: .net-app
name: dotnet-birdapi
path: ${{env.DOTNET_ROOT}}/BeakPeekApi

deploy:
runs-on: ubuntu-latest
needs: build
name: πŸš€ Deploy BirdApi
needs: [ build ]
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
Expand All @@ -71,10 +83,10 @@ jobs:

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: .net-app
name: dotnet-birdapi

- name: Login to Azure
uses: azure/login@v1
with:
Expand All @@ -89,4 +101,16 @@ jobs:
app-name: 'BeakPeekBirdApi'
slot-name: 'Production'
package: .


notify_discord:
name: πŸ”” Send Discord notification about deployment
needs: [deploy, build]
if: ${{ !cancelled() && (success() || failure()) }}
uses: ./.github/workflows/discord.yml
with:
content: "${{ contains(needs.deploy.result, 'success') && 'Successfully deployed' || 'Error during deployment of' }} ${{ github.ref_name }} for Azure"
title: "${{ contains(needs.deploy.result, 'success') && 'Successfully deployed' || 'Error during deployment of' }} ${{ github.ref_name }} for Azure"
url: ${{ needs.build.outputs.artifact_url }}
description: "${{ contains(needs.deploy.result, 'success') && 'Deployed:' || 'Deployment failed:' }} ${{ github.event.head_commit.message }}"
color: ${{ contains(needs.deploy.result, 'success') && 65280 || 16711680 }}
secrets: inherit
128 changes: 128 additions & 0 deletions .github/workflows/deploy_flutter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: πŸ“’ Publish Android release

on:
release:
types: [published]
# push:
# branches:
# - 'dev/feat/devops'
workflow_dispatch:
workflow_call:

env:
FLUTTER_CHANNEL: "stable"
RUBY_VERSION: "3.2.2"

jobs:
test_android:
name: πŸ§ͺ Test Flutter
uses: ./.github/workflows/flutter.yml
secrets: inherit

build_android:
name: πŸ›οΈ Build Android
needs: [test_android]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./beakpeek
timeout-minutes: 20
outputs:
artifact_url: ${{ steps.artifact-upload-step.outputs.artifact-url}}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
if: ${{ env.ACT }}
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Android SDK
if: ${{ env.ACT }}
uses: android-actions/setup-android@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
working-directory: './beakpeek/android'

- name: Run Flutter tasks
uses: subosito/[email protected]
with:
channel: stable
cache: true
pub-cache-key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}

- name: Create google_service_account.json
run: |
pwd
echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_BASE64 }}" | base64 --decode > google_service_account.json
- name: Create key.jks
run: |
pwd
echo "${{ secrets.ANDROID_KEYSTORE_FILE_BASE64 }}" | base64 --decode > android/app/upload-keystore.jks
- name: Create local.properties
run: |
pwd
echo "${{ secrets.ANDROID_LOCAL_PROPERTIES_FILE_BASE64 }}" | base64 --decode > android/local.properties
- name: Create key.properties
run: |
echo $PATH
pwd
cat <<EOF > android/key.properties
storePassword=${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
keyPassword=${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
keyAlias=upload
storeFile=\\\upload-keystore.jks
EOF
env:
ANDROID_KEY_STORE_PASSWORD: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}

# - name: Cache Flutter dependancies
# uses: actions/cache@v3
# with:
# path: |
# ~/.pub-cache
# ~/.flutter
# key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}

- name: Build and Release to Google Play
uses: maierj/[email protected]
with:
# lane: 'release_play_store'
lane: 'build'
subdirectory: ./beakpeek/android
options: '{ "version_number": "${{ github.ref_name }}" }'
env:
APP_PACKAGE_NAME: ${{ secrets.APP_PACKAGE_NAME }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: app-release
path: beakpeek/build/app/outputs/bundle/release/app-release.aab

notify_discord:
name: πŸ”” Send Discord notification about Build
needs: [build_android]
if: ${{ !cancelled() && (success() || failure()) }}
uses: ./.github/workflows/discord.yml
with:
content: "${{ contains(needs.build_android.result, 'success') && 'Successfully released' || 'Error during release of' }} ${{ github.ref_name }} for Android to Play Store"
title: "${{ contains(needs.build_android.result, 'success') && 'Successfully released' || 'Error during release of' }} ${{ github.ref_name }} for Android to Play Store"
url: ${{ needs.build_android.outputs.artifact_url }}
description: "${{ contains(needs.build_android.result, 'success') && 'Released:' || 'Release failed:' }} ${{ github.event.head_commit.message }}"
color: ${{ contains(needs.build_android.result, 'success') && 65280 || 16711680 }}
secrets: inherit

Loading

0 comments on commit 4c73956

Please sign in to comment.