Package ARM and Update Offer Artifact #29
This file contains 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
# Copyright (c) IBM Corporation. | |
# Copyright (c) Microsoft Corporation. | |
name: Package ARM and Update Offer Artifact | |
on: | |
workflow_dispatch: | |
inputs: | |
updateOfferArtifact: | |
description: 'Update offer artifact' | |
required: true | |
type: boolean | |
default: true | |
# Allows you to run this workflow using GitHub APIs | |
# PERSONAL_ACCESS_TOKEN=<GITHUB_PERSONAL_ACCESS_TOKEN> | |
# REPO_NAME=WASdev/azure.liberty.aro | |
# curl --verbose -XPOST -u "WASdev:${PERSONAL_ACCESS_TOKEN}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/${REPO_NAME}/actions/workflows/package.yaml/dispatches --data '{"ref": "main"}' | |
repository_dispatch: | |
types: [package] | |
# sample request | |
# PERSONAL_ACCESS_TOKEN=<GITHUB_PERSONAL_ACCESS_TOKEN> | |
# REPO_NAME=WASdev/azure.liberty.aro | |
# curl --verbose -X POST https://api.github.com/repos/${REPO_NAME}/dispatches -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" --data '{"event_type": "package"}' | |
env: | |
repoName: "azure.liberty.aro" | |
offerId: "20210823-liberty-aro" | |
planId: "liberty-aro" | |
clientId: ${{ secrets.CLIENT_ID }} | |
secretValue: ${{ secrets.SECRET_VALUE }} | |
tenantId: ${{ secrets.TENANT_ID }} | |
offerType: 'application_offer' | |
jobs: | |
package: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get versions of external dependencies | |
run: | | |
curl -Lo external-deps-versions.properties https://raw.githubusercontent.com/Azure/azure-javaee-iaas/main/external-deps-versions.properties | |
source external-deps-versions.properties | |
echo "bicepVersion=${BICEP_VERSION}" >> $GITHUB_ENV | |
- name: Download arm-ttk used in partner center pipeline | |
run: | | |
wget -O arm-template-toolkit.zip https://aka.ms/arm-ttk-azureapps | |
unzip arm-template-toolkit.zip -d arm-ttk | |
- name: Checkout ${{ env.repoName }} | |
uses: actions/checkout@v2 | |
with: | |
path: ${{ env.repoName }} | |
ref: ${{ github.event.inputs.ref }} | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
server-username: MAVEN_USERNAME # env variable for username | |
server-password: MAVEN_TOKEN # env variable for token | |
- name: Set Maven env | |
env: | |
MAVEN_USERNAME: github | |
MAVEN_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash | |
run: | | |
echo "MAVEN_USERNAME=${MAVEN_USERNAME}" >> "$GITHUB_ENV" | |
echo "MAVEN_TOKEN=${MAVEN_TOKEN}" >> "$GITHUB_ENV" | |
- name: Build and test ${{ env.repoName }} | |
run: | | |
cd ${{ env.repoName }} | |
mvn -Ptemplate-validation-tests clean install | |
- name: Generate artifact file name and path | |
id: artifact_file | |
run: | | |
version=$(awk '/<version>[^<]+<\/version>/{gsub(/<version>|<\/version>/,"",$1);print $1;exit;}' ${{ env.repoName }}/pom.xml) | |
artifactName=${{ env.repoName }}-$version-arm-assembly | |
unzip ${{ env.repoName }}/target/$artifactName.zip -d ${{ env.repoName }}/target/$artifactName | |
echo "##[set-output name=artifactName;]${artifactName}" | |
echo "##[set-output name=artifactPath;]${{ env.repoName }}/target/$artifactName" | |
echo "##[set-output name=artifactVersion;]${version}" | |
- name: Archive ${{ env.repoName }} template | |
uses: actions/upload-artifact@v4 | |
if: success() | |
with: | |
name: ${{steps.artifact_file.outputs.artifactName}} | |
path: ${{steps.artifact_file.outputs.artifactPath}} | |
- name: Update offer artifact | |
if: ${{ inputs.updateOfferArtifact == true || github.event.client_payload.updateOfferArtifact == true }} | |
uses: microsoft/microsoft-partner-center-github-action@v3 | |
with: | |
offerId: ${{ env.offerId }} | |
planId: ${{ env.planId }} | |
filePath: ${{ env.repoName }}/target/${{steps.artifact_file.outputs.artifactName}}.zip | |
artifactVersion: ${{steps.artifact_file.outputs.artifactVersion}} | |
clientId: ${{ env.clientId }} | |
secretValue: ${{ env.secretValue }} | |
tenantId: ${{ env.tenantId }} | |
offerType: ${{ env.offerType }} |