Azure Function - GitHub Maven Package #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a basic workflow to help you get started with Actions | |
| name: Azure Function - GitHub Maven Package | |
| on: | |
| # push: | |
| # paths: | |
| # - 'azure/**' | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| permissions: | |
| packages: write | |
| contents: read | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| #runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| dotnet-version: ['8.0.x'] | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} | |
| uses: actions/setup-dotnet@v1.7.2 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet-version }} | |
| - uses: actions/checkout@v2 | |
| - name: Set Version | |
| run: echo "PACKAGE_VERSION=$(Get-Date -Format "yyyy.M.d").${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| shell: pwsh | |
| - name: Create artifacts folder | |
| run: | | |
| mkdir "${{ github.workspace }}/artifacts" | |
| mkdir "${{ github.workspace }}/artifacts/process-message" | |
| mkdir "${{ github.workspace }}/azure/accept_message/node_modules" | |
| - name: Restore dependencies for process-message | |
| working-directory: azure/process_message/process_message | |
| run: dotnet restore | |
| - name: Build process-message | |
| # working-directory: azure/process_message/process_message | |
| working-directory: azure/process_message | |
| run: | | |
| dotnet build ./process_message.sln --configuration Release --no-restore --output "${{ github.workspace }}/artifacts/process-message" | |
| - name: Configure Maven Settings File | |
| shell: pwsh | |
| run: | | |
| $settingFile = @" | |
| <settings> | |
| <servers> | |
| <server> | |
| <id>octopus-sales-public-release</id> | |
| <username>${{ secrets.AWS_ACCESS_KEY }}</username> | |
| <password>${{ secrets.AWS_SECRET_KEY }}</password> | |
| <configuration> | |
| <region>ap-southeast-2</region> | |
| <publicRepository>true</publicRepository> | |
| </configuration> | |
| </server> | |
| </servers> | |
| </settings> | |
| "@ | |
| $settingFile | Out-File -FilePath "${{ github.workspace }}/artifacts/settings.xml" -Encoding utf8 | |
| - name: Create process-message zip file | |
| uses: OctopusDeploy/create-zip-package-action@v3 | |
| with: | |
| package_id: "OctopusSamples.process-message" | |
| version: "${{ env.PACKAGE_VERSION }}" | |
| output_folder: "${{ github.workspace }}/artifacts" | |
| base_path: "${{ github.workspace }}/artifacts/process-message" | |
| files: | | |
| **/* | |
| - name: run npm install | |
| working-directory: azure/accept_message | |
| run: | | |
| npm ci --production | |
| - name: Create accept-message zip file | |
| uses: OctopusDeploy/create-zip-package-action@v3 | |
| with: | |
| package_id: "OctopusSamples.accept-message" | |
| version: "${{ env.PACKAGE_VERSION }}" | |
| output_folder: "${{ github.workspace }}/artifacts" | |
| base_path: "${{ github.workspace }}/azure/accept_message" | |
| files: | | |
| **/* | |
| - name: Install maven-repository-aws-s3 dependencies | |
| run: | | |
| HOME=$(dirname $(readlink -f $(which mvn))) | |
| for dep in "com.github.ehsaniara:maven-repository-aws-s3:1.2.11:jar" "org.apache.httpcomponents:httpcore:4.4.16:jar" "com.amazonaws:aws-java-sdk-s3:1.12.405:jar" "com.amazonaws:aws-java-sdk-core:1.12.405:jar" "com.fasterxml.jackson.core:jackson-core:2.14.2:jar" "com.fasterxml.jackson.core:jackson-databind:2.14.2:jar" "com.fasterxml.jackson.core:jackson-annotations:2.14.2:jar" "joda-time:joda-time:2.12.2:jar" "org.apache.httpcomponents:httpclient:4.5.14:jar" "commons-io:commons-io:2.12.0" | |
| do | |
| mvn dependency:copy \ | |
| --batch-mode \ | |
| -DrepoUrl=https://repo.maven.apache.org/maven2 \ | |
| -Dartifact=${dep} \ | |
| -DoutputDirectory=${HOME}/../lib | |
| done | |
| shell: bash | |
| working-directory: "${{ github.workspace }}/artifacts" | |
| - name: Push process-message package to Maven feed | |
| run: | | |
| mvn deploy:deploy-file -s "${{ github.workspace }}/artifacts/settings.xml" ` | |
| --batch-mode ` | |
| "-DgroupId=com.octopus" ` | |
| "-DartifactId=OctopusSamples.process-message" ` | |
| "-Dversion=${{ env.PACKAGE_VERSION }}" ` | |
| "-Dpackaging=zip" ` | |
| "-Dfile=${{ github.workspace }}/artifacts/OctopusSamples.process-message.${{ env.PACKAGE_VERSION }}.zip" ` | |
| "-DrepositoryId=octopus-sales-public-release" ` | |
| "-Durl=s3://octopus-sales-public-maven-repo/snapshot" ` | |
| shell: pwsh | |
| working-directory: "${{ github.workspace }}/artifacts" | |
| - name: Push accept-message package to Maven feed | |
| run: | | |
| mvn deploy:deploy-file -s "${{ github.workspace }}/artifacts/settings.xml" ` | |
| --batch-mode ` | |
| "-DgroupId=com.octopus" ` | |
| "-DartifactId=OctopusSamples.accept-message" ` | |
| "-Dversion=${{ env.PACKAGE_VERSION }}" ` | |
| "-Dpackaging=zip" ` | |
| "-Dfile=${{ github.workspace }}/artifacts/OctopusSamples.accept-message.${{ env.PACKAGE_VERSION }}.zip" ` | |
| "-DrepositoryId=octopus-sales-public-release" ` | |
| "-Durl=s3://octopus-sales-public-maven-repo/snapshot" ` | |
| shell: pwsh | |
| working-directory: "${{ github.workspace }}/artifacts" |