Skip to content

Build and publish image #12

Build and publish image

Build and publish image #12

Workflow file for this run

name: Build and publish image
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-test-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: checkout
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: nelonoel/branch-name@v1.0.1
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
#build the image and push it to the registry
- uses: mr-smithers-excellent/docker-build-push@v5
name: push-container-image
with:
image: mega-frontend
registry: ghcr.io
dockerfile: Containerfile
buildArgs: BRANCH=${BRANCH_NAME},COMMIT=${{ steps.vars.outputs.sha_short }},VERSION=${{ steps.vars.outputs.sha_short }}
username: ${{ github.repository }}
password: ${{ secrets.GITHUB_TOKEN }}
addLatest: ${{ github.ref == 'refs/heads/main' }}