forked from microsoft/vscode-dev-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (101 loc) · 3.82 KB
/
version-history.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Update version history
on:
workflow_dispatch:
inputs:
release:
description: 'Release branch or tag'
required: true
default: 'main'
cg:
description: 'Generate cgmanifest.json'
required: true
default: 'false'
push:
description: 'Update repository with results'
required: true
default: 'true'
overwrite:
description: 'Overwrite existing files'
required: true
default: 'true'
definition:
description: 'Definition ID (Optional)'
required: false
default: ''
jobs:
image_info:
name: Update version history
runs-on: ubuntu-latest
steps:
- name: Free more space
id: free_space
run: |
set -e
# Ensure enough space is available for build
sudo apt-get autoremove -y
sudo apt-get clean -y
sudo rm -rf /usr/share/dotnet
- name: Checkout ref
id: checkout_ref
uses: actions/checkout@v2
with:
path: 'ref'
ref: ${{ github.ref }}
- name: Checkout release
id: checkout_release
uses: actions/checkout@v2
with:
path: 'release'
ref: ${{ github.event.inputs.release }}
- name: Azure CLI login
id: az_login
uses: azure/login@v1
with:
creds: ${{ secrets.AZ_ACR_CREDS }}
- name: Get image info
id: Get_image_info
run: |
set -e
# ACR login
ACR_REGISTRY_NAME=$(echo ${{ secrets.REGISTRY }} | grep -oP '(.+)(?=\.azurecr\.io)')
az acr login --name $ACR_REGISTRY_NAME
# Go to the release, copy the build tool from ref since this is the version for the workflow
cd "$GITHUB_WORKSPACE/release"
rm -rf build node_modules
cp -r "$GITHUB_WORKSPACE/ref/build" "$GITHUB_WORKSPACE/release/"
yarn install
# Pull images and update cgmanifest.json, but output back to ref
build/vscdc info --no-build \
--markdown \
--prune \
--release ${{ github.event.inputs.release }} \
--registry ${{ secrets.REGISTRY }} \
--registry-path ${{ secrets.REGISTRY_BASE_PATH }} \
--stub-registry ${{ secrets.STUB_REGISTRY }} \
--stub-registry-path ${{ secrets.STUB_REGISTRY_BASE_PATH }} \
--output-path "$GITHUB_WORKSPACE/ref" \
$(if [ "${{ github.event.inputs.overwrite }}" = "false" ]; then echo '--no-overwrite'; else echo '--overwrite'; fi) \
$(if [ "${{ github.event.inputs.cg }}" = "false" ]; then echo '--no-cg'; else echo '--cg'; fi) \
${{ github.event.inputs.definition }}
- name: Push image information
id: push_image_info
run: |
set -e
# Push updates to ref
cd "$GITHUB_WORKSPACE/ref"
GIT_BRANCH=$(echo "${{ github.ref }}" | grep -oP 'refs/(heads|tags)/\K(.+)')
if [ "$GIT_BRANCH" == "" ]; then
GIT_BRANCH=main
fi
git config --global user.email "vscr-feedback@microsoft.com"
git config --global user.name "CI"
git config pull.rebase false
# Pull in anything that may have come in
git pull "https://ci:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" "HEAD:$GIT_BRANCH"
# Add / update and commit
git add -A
git commit -m 'Automated update for image history' || export NO_UPDATES=true
# Push (unless disabled for testing)
if [ "$NO_UPDATES" != "true" ] && [ "${{ github.event.inputs.push }}" = "true" ]; then
git push "https://ci:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" "HEAD:$GIT_BRANCH"
fi