Skip to content

Commit

Permalink
build(gha): update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapenbr committed Dec 28, 2022
1 parent 1d0c2cf commit 2d78bf8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
44 changes: 34 additions & 10 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,35 @@ on:
push:
tags:
- "*"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Prep
id: prep
run: |
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/istint-web
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${GHCR_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${GHCR_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "ghcr_image=${GHCR_IMAGE}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Cache node modules
uses: actions/cache@v2
env:
Expand All @@ -22,7 +45,7 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js 18
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install dependencies
Expand All @@ -38,12 +61,13 @@ jobs:
CI: false
- name: Copy to docker
run: cp -r build/ docker/build
- name: Build and push docker image
uses: docker/build-push-action@v1
- name: Build and push
uses: docker/build-push-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
path: docker
registry: docker.pkg.github.com
repository: mpapenbr/istint/istint-web
tag_with_ref: true
context: docker
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
6 changes: 3 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
Expand All @@ -22,7 +22,7 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
- name: Use Node.js 18
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install dependencies
Expand Down

0 comments on commit 2d78bf8

Please sign in to comment.