Build and Release #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 Release | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
release: | |
runs-on: arc-runner-k8s | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
pages: write | |
id-token: write | |
outputs: | |
published: ${{ steps.semantic.outputs.new_release_published }} | |
version: ${{ steps.semantic.outputs.new_release_version }} | |
steps: | |
- name: Force Install GIT latest | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y software-properties-common | |
sudo add-apt-repository -y ppa:git-core/ppa | |
sudo apt-get update | |
sudo apt-get install -y git | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Checkout the repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Build distribution | |
run: | | |
npm ci | |
npm run build | |
- name: Build a tarball | |
run: tar -czf unipoll-app.tar.gz dist/unipoll-app | |
- name: Cleanup dist folder | |
run: rm -rf dist/unipoll-app | |
- name: Semantic Release | |
id: semantic | |
uses: cycjimmy/semantic-release-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
docker: | |
runs-on: arc-runner-k8s | |
needs: release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Context for Buildx | |
id: buildx-context | |
run: | | |
docker context create builders | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: latest | |
endpoint: builders | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
if: needs.release.outputs.published == 'true' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: unipoll/web-app:${{ needs.release.outputs.version }}, unipoll/web-app:latest |