Publish Dependencies Image #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Dependencies Image | |
on: | |
workflow_dispatch: | |
inputs: | |
build_secret: | |
type: string | |
description: Build secret | |
push: | |
branches: | |
- release | |
- fake-release | |
- deps-image | |
jobs: | |
build: | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check secret | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
if [ "${{ github.event.inputs.build_secret }}" != "${{ secrets.BUILD_SECRET }}" ]; then | |
echo "Wrong build secret." | |
exit 1 | |
fi | |
- name: Check user permission | |
if: github.event_name == 'workflow_dispatch' | |
id: check | |
uses: scherermichael-oss/action-has-permission@master | |
with: | |
required-permission: write | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
run: | | |
echo $CR_PAT | docker login ghcr.io -u stjude --password-stdin | |
env: | |
CR_PAT: ${{ secrets.PAT }} | |
# Setup .npmrc file to publish to GitHub Packages | |
- uses: actions/setup-node@v3 | |
with: | |
cache: 'npm' | |
node-version: '16' | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@sjcrh' | |
- name: Build image | |
run: | | |
# npm ci | |
cd container/deps | |
./version.sh -c | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [[ "$BRANCH" != "release" && ${{ github.event_name != 'workflow_dispatch' }} ]]; then | |
echo "skipping build and publishing" | |
else | |
./build.sh -m "ghcr.io/stjude/" | |
HASH=$(git rev-parse --short HEAD 2>/dev/null) | |
TAG="$(node -p "require('./package.json').version")-$HASH" | |
HASH=$(git rev-parse --short HEAD) | |
docker push ghcr.io/stjude/ppserver:$TAG-$HASH | |
docker push ghcr.io/stjude/ppfull:$TAG-$HASH | |
docker push ghcr.io/stjude/ppserver:latest | |
docker push ghcr.io/stjude/ppfull:latest | |
echo "merging to master" | |
git checkout master | |
git merge release | |
git push | |
fi |