Skip to content

Merge pull request #347 from emmairwin/main #215

Merge pull request #347 from emmairwin/main

Merge pull request #347 from emmairwin/main #215

Workflow file for this run

name: Build the content
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '.github/workflows/*.yml'
env:
REGISTRY: docker.pkg.github.com
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
#services:
#sitebuildercontainer:
#image: docker.pkg.github.com/microsoft/opensource.microsoft.com/xxx:latest
#credentials:
#username: ${{ github.actor }}
#password: ${{ secrets.GITHUB_TOKEN }}
steps:
# actions/checkout@v2 on 11/4/2021
- uses: actions/checkout@230611dbd0eb52da1e1f4f7bc8bb0c3a339fc8b7
name: "Check it out"
- name: "Startup"
run: pwd
- name: Package registry login
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
#- name: Login to GitHub Packages
# run: |
# run: echo ${{ secrets.READONLY_PACKAGE_TOKEN }} | docker login -u ${{ secrets.READONLY_PACKAGE_SP }} --password-stdin
# login-server: 'docker.pkg.github.com'
- name: "Build the site"
run: |
docker run -i -v ${PWD}:/usr/local/site docker.pkg.github.com/microsoft/opensource.microsoft.com/custom-jekyll-builder:latest sh << COMMANDS
pwd && whoami
cd /usr/local/site
ls -la
bundle install
npm i
./node_modules/gulp/bin/gulp.js build
JEKYLL_ENV=opensource.microsoft.com jekyll build
COMMANDS
- name: "Write content.json"
env:
GITSHA: ${{ github.sha }}
run: |
echo "{\"commitId\":\"$GITSHA\"}" > content.json
cat ./content.json
cp content.json _site/
- name: "Compress the static site"
run: zip -r ../site.zip .
working-directory: /home/runner/work/opensource.microsoft.com/opensource.microsoft.com/_site
# actions/upload-artifact/v2 on 11/4/2021
- uses: actions/upload-artifact@6fc84b101e3160d153b2b53314fa13f02a36ae96
name: "Store the site as an artifact"
with:
name: website
path: /home/runner/work/opensource.microsoft.com/opensource.microsoft.com/site.zip
- name: "Connect to Azure Files"
env:
AZURE_FILES_ENDPOINT: ${{ secrets.AZURE_FILES_ENDPOINT }}
AZURE_FILES_SP: ${{ secrets.AZURE_FILES_SP }}
AZURE_FILES_USERNAME: ${{ secrets.AZURE_FILES_USERNAME }}
run: |
echo Making mountpoint /mnt/files
sudo mkdir -p /mnt/files
echo Preparing creds...
if [ ! -d "/etc/smbcredentials" ]; then
echo creating smb creds folder
sudo mkdir /etc/smbcredentials
fi
echo Preparing share-specific creds...
if [ ! -f "/etc/smbcredentials/files.cred" ]; then
echo Storing share info...
echo username=$AZURE_FILES_USERNAME >> ./files.cred
echo password=$AZURE_FILES_SP >> ./files.cred
sudo mv ./files.cred /etc/smbcredentials/
fi
echo Setting file mode...
sudo chmod 600 /etc/smbcredentials/files.cred
echo Writing to /etc/fstab
echo Mounting...
sudo mount -t cifs //$AZURE_FILES_ENDPOINT/dev /mnt/files -o vers=3.0,credentials=/etc/smbcredentials/files.cred,dir_mode=0777,file_mode=0777,serverino
- name: "Copy site"
working-directory: /home/runner/work/opensource.microsoft.com/opensource.microsoft.com
run: |
cp site.zip /mnt/files/
cp content.json /mnt/files/
- name: "Disconnect from Azure Files"
run: |
sudo umount /mnt/files
- name: "Prepare to AzCopy..."
working-directory: /home/runner/work
run: |
mkdir azcopy
cd azcopy
wget https://aka.ms/downloadazcopy-v10-linux
mv downloadazcopy-v10-linux azcopy.tar.gz
tar -xvf azcopy.tar.gz
mv azcopy_linux* azcopy_linux
mv azcopy_linux/azcopy ./
ls -la
- name: "Copy to CDN"
working-directory: /home/runner/work/azcopy
env:
SASTOKEN: ${{ secrets.AZURE_CDN_SAS }}
run: |
./azcopy sync /home/runner/work/opensource.microsoft.com/opensource.microsoft.com/_site "https://osssite.blob.core.windows.net/cdn/$SASTOKEN" --recursive=true
- name: "Copy to static web container"
working-directory: /home/runner/work/azcopy
env:
SASTOKEN: ${{ secrets.AZURE_WEB_SAS }}
run: |
./azcopy sync /home/runner/work/opensource.microsoft.com/opensource.microsoft.com/_site "https://osssite.blob.core.windows.net/\$web/$SASTOKEN" --recursive=true