generated from the-gophers/go-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (43 loc) · 1.68 KB
/
0-azure-storage.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
name: 0-azure-storage
on:
workflow_dispatch:
inputs:
storage_container_url:
description: 'Storage Container URL'
default: 'https://storage_account_name.blob.core.windows.net/container_name/'
required: true
prefix:
description: 'Prefix (no trailing slash)'
default: 'latest'
required: true
jobs:
azcopy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: azcopy install
run: |
echo "installing azcopy"
sudo mkdir -p /home/azcopy/
curl -L https://aka.ms/downloadazcopy-v10-linux | tar -zxf - --directory /home/azcopy/
sudo mv $(find /home/azcopy/ -type f -name azcopy) /usr/bin/
- name: azcopy sync
env:
SOURCE_DIRECTORY: .
AZURE_STORAGE_CONTAINER_URL: ${{ github.event.inputs.storage_container_url }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
GITHUB_SHA: ${{ github.sha }}
PREFIX: ${{ github.event.inputs.prefix }}
run: |
# login to azcopy with AZURE_CREDENTIALS
export AZCOPY_SPA_CLIENT_SECRET=$(echo "$AZURE_CREDENTIALS" | jq -r .clientSecret)
CLIENT_ID=$(echo "$AZURE_CREDENTIALS" | jq -r .clientId)
azcopy login --service-principal --application-id "${CLIENT_ID}"
# set prefix
cd $SOURCE_DIRECTORY
[[ -z "${PREFIX:-}" ]] && PREFIX="${GITHUB_REF#refs/heads/}"
[[ -z "${PREFIX:-}" ]] && PREFIX='latest'
echo $PWD
azcopy sync . "${AZURE_STORAGE_CONTAINER_URL}${PREFIX}" --delete-destination=true --exclude-path=.git
echo "${AZURE_STORAGE_CONTAINER_URL}${PREFIX}"
azcopy list "${AZURE_STORAGE_CONTAINER_URL}${PREFIX}"