Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare repo for automatically updating az_quickstart on new release. #22

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions .github/workflows/cdn-deploy-release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
name: Build, tag, & deploy CDN assets for release
name: Deploy CDN assets for release
on:
workflow_dispatch:
inputs:
version:
description: The version to tag and release
required: true

repository_dispatch:
types: az_icons_release
jobs:
deploy:
name: Build & deploy CDN assets
runs-on: ubuntu-20.04

name: Deploy CDN assets
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -24,17 +19,6 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ github.event.inputs.version }}"
release_name: "v${{ github.event.inputs.version }}"
draft: false
prerelease: false

- name: Deploy CDN assets to S3 + CloudFront
run: |
aws s3 sync --delete --cache-control max-age=691200 dist/. s3://${{ secrets.AZ_DIGITAL_CDN_BUCKET }}/lib/az-icons/${{ github.event.inputs.version }}/
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: The version to tag and release
required: true

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.AZ_ICONS_DEPLOY_KEY }}

- name: Set variables for Docker images
run: |
oldhash=${{ hashFiles('Dockerfile', 'package.json', 'package-lock.json', 'scripts/*') }}
registry='ghcr.io'
imageprefix="${registry}/${GITHUB_REPOSITORY}/"
imagename='az-nodejs-ephemeral'
imagestem="${imageprefix}${imagename}:"
echo "AZ_DOCKER_REGISTRY=${registry}" >> ${GITHUB_ENV}
echo "AZ_OLD_HASH=${oldhash}" >> ${GITHUB_ENV}
echo "AZ_IMAGE_STEM=${imagestem}" >> ${GITHUB_ENV}
echo "AZ_ICONS_SOURCE_DIR=az-icons-src" >> ${GITHUB_ENV}
echo "AZ_ICONS_FROZEN_DIR=/azbuild/az-icons" >> ${GITHUB_ENV}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker authentication
run: |
docker login "$AZ_DOCKER_REGISTRY" -u "$GITHUB_ACTOR" -p ${{ secrets.GITHUB_TOKEN }}

- name: Unconditionally rebuild and save the Docker image
run: |
workingtitle=$(docker build -q . )
tempname="old${AZ_OLD_HASH}"
docker run --name "$tempname" "$workingtitle" true
docker cp -a "${tempname}:${AZ_BOOTSTRAP_FROZEN_DIR}/." .
docker rm "$tempname"
lockhash=${{ hashFiles('Dockerfile', 'package.json', 'package-lock.json', 'scripts/*') }}
ephemeral="${AZ_IMAGE_STEM}${lockhash}"
docker tag "$workingtitle" "$ephemeral"
docker push "$ephemeral"
echo "AZ_EPHEMERAL_IMAGE=${ephemeral}" >> ${GITHUB_ENV}

- name: Build variables
run: |
echo "AZ_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV}

- name: Update version
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
docker run --rm -e "AZ_RELEASE_VERSION=${AZ_VERSION}" -v $(pwd):"/${AZ_ICONS_SOURCE_DIR}" "$AZ_EPHEMERAL_IMAGE" create-release
git add dist package.json package-lock.json
git commit -m '${{ github.event.inputs.version }}'
git push
echo "RELEASE_SHA=$(git rev-parse HEAD)" >> ${GITHUB_ENV}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commitish: "${{ env.RELEASE_SHA }}"
tag_name: "v${{ env.AZ_VERSION }}"
release_name: "v${{ env.AZ_VERSION }}"
draft: false
prerelease: false #${{ contains(env.AZ_VERSION, '-alpha') }}

- name: Save new SHA to file
run: |
echo "{\"sha\": \"$(git rev-parse HEAD)\"}" > ${{ runner.temp }}/variables.json

- name: Upload variables
uses: actions/upload-artifact@v4
with:
name: variables-json-artifact
path: ${{ runner.temp }}

dispatch:
needs: release
strategy:
matrix:
repo:
- az-digital/az-icons
- az-digital/az-icons-packagist
runs-on: ubuntu-latest
steps:
- name: Download variables
uses: actions/download-artifact@v4
with:
name: variables-json-artifact
path: ${{ runner.temp }}

- name: Update environment variables
run: |
variablesfile=${{ runner.temp }}/variables.json
echo "RELEASE_SHA=$(cat ${variablesfile} | jq -r '.sha' )" >> ${GITHUB_ENV}
echo "BRANCH_NAME=${GITHUB_REF_NAME}" >> ${GITHUB_ENV}

- name: Notify dependencies
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: ${{ matrix.repo }}
event-type: az_icons_release
client-payload: '{"version": "${{ github.event.inputs.version }}", "ref": "${{ env.RELEASE_SHA }}", "sha": "${{ env.RELEASE_SHA }}", "branch": "${{env.BRANCH_NAME}}"}'
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ az-icons
└── src
├── az-icons-styles.css
├── fonts
├── az-icons.eot
├── az-icons.svg
├── az-icons.ttf
└── az-icons.woff
   ├── az-icons.eot
   ├── az-icons.svg
   ├── az-icons.ttf
   └── az-icons.woff
├── png
└── *.png
   └── *.png
└── svg
└── *.svg
```
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Arizona Icons is Copyright (C) 2019-2022
Arizona Icons is Copyright (C) 2019-2024
The Arizona Board of Regents on behalf of The University of Arizona.
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM --platform=linux/amd64 node:20.11.0-bookworm-slim

ENV LANG C.UTF-8

COPY scripts/copy-npm-config.sh /usr/local/bin/copy-npm-config
COPY scripts/create-release.sh /usr/local/bin/create-release

# Build args don't normally persist as environment variables.
ARG AZ_ICONS_FROZEN_DIR
ENV AZ_ICONS_FROZEN_DIR ${AZ_ICONS_FROZEN_DIR:-/azbuild/az-icons}
ARG AZ_ICONS_SOURCE_DIR
ENV AZ_ICONS_SOURCE_DIR ${AZ_ICONS_SOURCE_DIR:-/az-icons-src}

# Silence warnings from the update-notifier npm package.
ENV NO_UPDATE_NOTIFIER 1

WORKDIR $AZ_ICONS_SOURCE_DIR

COPY "package.json" "$AZ_ICONS_FROZEN_DIR"/

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
git \
python3 \
python3-pip \
python3-setuptools \
python3-wheel \
rsync \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install 'awscli~=1.19.41' \
&& cd "${AZ_ICONS_FROZEN_DIR}" \
&& npm config set cache='/tmp/.npm' \
&& chmod 755 /root \
&& chmod 644 /root/.npmrc \
&& npm install --location=global [email protected] \
&& npm install \
&& find node_modules -name '.DS_Store' -exec rm {} \;
1 change: 0 additions & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,5 @@ <h1>Font Test Drive</h1>
<p class="mhl">Generated by <a href="https://icomoon.io/app">IcoMoon</a></p>
</div>

<script src="demo-files/demo.js"></script>
</body>
</html>
Loading