Misc #335
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
# Create containers and deploy to a test environment | |
# --- | |
# Note that this workflow uses OpenID Connect for secretless deployment to Azure. | |
# | |
# Variables that are not secrets and can be configured as Actions variables _or_ secrets: | |
# - AAD tenant ID, subscription ID, client ID for OpenID Connect | |
# - Azure Container Registry name and username | |
# - App Service endpoints, app names, and slot names | |
# - Test environment URLs | |
name: Ship it πΏοΈ | |
on: | |
push: | |
branches: [main] | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
lint-and-test: | |
name: "Lint 'n test π§Ί" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout π | |
uses: actions/checkout@v4 | |
- name: Packages π¦ | |
run: | | |
npm ci | |
- name: Lint π | |
run: | | |
npm run lint | |
- name: Test πββοΈ | |
run: | | |
npm run test | |
# npm run-script build | |
# npm run-script test:ci | |
build: | |
name: 'Container delivery π' | |
runs-on: ubuntu-latest | |
environment: | |
name: development | |
steps: | |
- uses: actions/checkout@v4 | |
#- uses: docker/build-push-action@v3 | |
- name: Azure OpenID Connect β¨ | |
if: github.repository == 'microsoft/opensource-management-portal' # official repo only | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.CLIENT_ID }} | |
tenant-id: ${{ secrets.TENANT_ID }} | |
subscription-id: ${{ secrets.SUBSCRIPTION_ID }} | |
- name: Connect to Azure Container Registry π | |
if: github.repository == 'microsoft/opensource-management-portal' # official repo only | |
run: | | |
az acr login -n opensource | |
- name: Stamp build information π | |
run: | | |
sed -i "s/__Build_BuildNumber__/${{ github.run_number }}/" package.json | |
sed -i "s/__Build_SourceVersion__/${{ github.sha }}/" package.json | |
echo package.json-stamped version: | |
cat package.json | |
- name: Use opensource deployment values π | |
if: github.repository == 'microsoft/opensource-management-portal' # official repo only | |
run: | | |
node .ossdev/build/packageBurn.js | |
node .ossdev/build/dockerfileForEnvironment.js | |
- name: Container build β΄οΈ | |
run: | | |
docker build \ | |
-t ${{ github.event.repository.name }}:${{ github.run_number }} \ | |
-t opensource.azurecr.io/${{ github.event.repository.name }}:${{ github.run_number }} \ | |
-t opensource.azurecr.io/${{ github.event.repository.name }}:latest \ | |
. | |
- name: Push to ACR π | |
if: github.repository == 'microsoft/opensource-management-portal' # official repo only | |
run: | | |
docker image push opensource.azurecr.io/${{ github.event.repository.name }}:${{ github.run_number }} | |
docker image push opensource.azurecr.io/${{ github.event.repository.name }}:latest | |
development-stage: | |
name: Stage to development ποΈ | |
if: github.repository == 'microsoft/opensource-management-portal' # official repo only | |
runs-on: ubuntu-latest | |
needs: [build, lint-and-test] | |
environment: | |
name: development | |
url: https://portal-staging.ospo.dev | |
steps: | |
- name: Azure OpenID Connect β¨ | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.CLIENT_ID }} | |
tenant-id: ${{ secrets.TENANT_ID }} | |
subscription-id: ${{ secrets.SUBSCRIPTION_ID }} | |
- name: Prepare staging slots π° | |
run: | | |
az webapp config container set \ | |
--docker-custom-image-name opensource.azurecr.io/${{ github.event.repository.name }}:${{ github.run_number }} \ | |
--docker-registry-server-url https://opensource.azurecr.io \ | |
--name portalwestus3 \ | |
--resource-group portal \ | |
--slot staging | |
development: | |
name: Swap to live ποΈ | |
if: github.repository == 'microsoft/opensource-management-portal' # official repo only | |
runs-on: ubuntu-latest | |
needs: [development-stage] | |
environment: | |
name: development | |
url: https://portal.ospo.dev | |
steps: | |
- name: Azure OpenID Connect β¨ | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.CLIENT_ID }} | |
tenant-id: ${{ secrets.TENANT_ID }} | |
subscription-id: ${{ secrets.SUBSCRIPTION_ID }} | |
- name: Swap staging to live π | |
run: | | |
az webapp deployment slot swap \ | |
--name portalwestus3 \ | |
--resource-group portal \ | |
--slot staging |