Skip to content

Build & deploy

Build & deploy #44

Workflow file for this run

name: Build & deploy
env:
# Change this to upload the built image to your own organization.
docker_tag: 'ghcr.io/tietokilta/ilmomasiina'
# Change these to customize your build.
branding_header_title_text: 'Tietokillan ilmomasiina'
branding_footer_gdpr_text: 'Tietosuoja'
branding_footer_gdpr_link: 'https://tietokilta.fi/kilta/hallinto/viralliset-asiat/rekisteriselosteet/'
branding_footer_home_text: 'Tietokilta.fi'
branding_footer_home_link: 'https://tietokilta.fi'
branding_login_placeholder_email: '[email protected]'
on:
push:
branches:
- prod
- staging
tags:
- 'v*'
jobs:
lint:
name: Lint & type-check
uses: ./.github/workflows/lint.yml
docker:
name: Push Docker image to GitHub Packages
needs: lint
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
# Change this to your repo name to build automatically on your fork.
if: github.repository == 'Tietokilta/ilmomasiina'
steps:
-
name: Check out the repo
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.docker_tag }}
flavor: |
latest=${{ github.ref == 'refs/heads/prod' }}
tags: |
type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref_type == 'tag' }}
type=ref,event=branch,enable=${{ github.ref_type == 'branch' }}
type=sha
-
name: Push to GitHub Packages
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Customize your build here
build-args: |
BRANDING_HEADER_TITLE_TEXT=${{ env.branding_header_title_text }}
BRANDING_FOOTER_GDPR_TEXT=${{ env.branding_footer_gdpr_text }}
BRANDING_FOOTER_GDPR_LINK=${{ env.branding_footer_gdpr_link }}
BRANDING_FOOTER_HOME_TEXT=${{ env.branding_footer_home_text }}
BRANDING_FOOTER_HOME_LINK=${{ env.branding_footer_home_link }}
BRANDING_LOGIN_PLACEHOLDER_EMAIL=${{ env.branding_login_placeholder_email }}
# This is disabled on forks, you'll most likely need to modify it anyway for your usage
deploy:
name: Push update to App Service
needs: docker
if: github.ref_type == 'branch' && github.repository == 'Tietokilta/ilmomasiina'
runs-on: ubuntu-latest
environment: production
steps:
-
name: Login via Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
-
uses: azure/webapps-deploy@v2
with:
app-name: tik-ilmo-${{ github.ref_name }}-app
images: '${{ env.docker_tag }}:${{ github.ref_name }}'
# This is disabled on forks since you probably don't need to upload your own packages
npm:
name: Publish JS packages
needs: lint
permissions:
packages: write
contents: read
if: github.ref_type == 'tag' && github.repository == 'Tietokilta/ilmomasiina'
uses: ./.github/workflows/npm-build.yml
secrets: inherit