add build environments, test actionas build process/image #15
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: Build and publish image | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
workflow_dispatch: | |
jobs: | |
build-test-push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
name: checkout | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
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/[email protected] | |
- name: Set outputs | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- uses: mr-smithers-excellent/[email protected] | |
name: push-container-image | |
with: | |
image: gepardec-gamertrack-frontend | |
registry: ghcr.io | |
multiPlatform: true | |
platform: linux/amd64,linux/arm64 | |
username: ${{ github.repository }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# if the branch is main, add the latest tag | |
addLatest: ${{ github.ref == 'refs/heads/main' }} |