This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
Add build and release workflows #62
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: Continuous Integration | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
jobs: | |
app: | |
name: Continuous Integration | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: yarn | |
- name: Lint | |
run: yarn lint | |
- name: Test | |
run: yarn test | |
- name: Build | |
run: yarn build | |
build: | |
name: Build application | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-22.04 | |
needs: | |
- app | |
steps: | |
- name: Set version | |
run: | | |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
driver-opts: image=moby/buildkit:master | |
- name: Login to Github Packages | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push app to GitHub Packages | |
uses: docker/[email protected] | |
with: | |
file: Dockerfile | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.VERSION }} | |
release: | |
name: Create release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-22.04 | |
needs: build | |
steps: | |
- name: Set version | |
run: | | |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
- name: Create Github Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.event.repository.name }} ${{ env.VERSION }} | |
prerelease: contains(github.ref, '-') | |
body: | | |
Application ${{ github.event.repository.name }} ${{ env.VERSION }} was released |