-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathbuild.yml
executable file
·82 lines (63 loc) · 2.11 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
submodules: true
- script: |
sudo chmod -R 777 /home/vsts/work/1/s
ls -l /home/vsts/work/1/s/.npmrc
displayName: 'Add vsts directory permissions'
# Authenticate to NPM
- task: NpmAuthenticate@0
inputs:
workingFile: '.npmrc'
displayName: 'Authenticate to NPM'
# Build steps for the project
- script: |
cd src
tsc -t es2015 ms-store-badge.ts
npm install
npm run build:prod
displayName: 'Build badge'
# Deploy to Azure Static Web App
- task: AzureStaticWebApp@0
inputs:
app_location: '/'
api_location: ''
output_location: '/dist' # Built app content directory relative to app_location
azure_static_web_apps_api_token: $(DEPLOYMENT_TOKEN)
displayName: 'Deploy to SWA'
# Publish build artifacts
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/dist'
ArtifactName: 'ms-store-badge-artifacts'
publishLocation: 'Container'
displayName: 'Publish build artifact'
# Sync ADO Repo to GitHub Repo
- script: |
echo "Setting up GitHub repository"
# Configure Git to use the stored GitHub token
git config --global user.name "Justin Lau"
git config --global user.email "[email protected]"
# Add remote GH badge repo
git remote add github https://$(GITHUB_TOKEN)@github.com/microsoft/app-store-badge.git
# Fetch the latest changes
git fetch github
# Ensure we are on the GH main branch
git checkout github/main
# Merge changes from ADO repository, take our side by default, and allow unrelated histories
git merge origin/main -X ours --allow-unrelated-histories --no-edit
# Remove .npmrc file
git rm .npmrc -f
# Add changes
git add -A
# Commit changes
git commit -m "Sync from ADO repo" || echo "No changes to commit"
# Push the changes to GH
git push github HEAD:main --force
displayName: 'Sync ADO Repo to GitHub'
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)