⬆️ Bump the npm_and_yarn group across 1 directory with 2 updates #41
Workflow file for this run
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: 🔄 Build, release, push and deploy | |
on: | |
push: | |
branches: ["main", "beta", "*.*.*"] | |
pull_request: | |
branches: ["main", "beta", "*.*.*"] | |
# Used by the GitHub merge queue feature. | |
# Documentation: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue | |
merge_group: | |
env: | |
NAMESPACE_NAME: "docs" | |
IMAGE_NAME: "docs" | |
jobs: | |
build: | |
name: ⚙️ Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x, current] | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: 🌐 Use Node.js [${{ matrix.node-version }}] | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: 🗂 Cache "node_modules" | |
uses: actions/cache@v3 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: "**/node_modules" | |
key: ${{ runner.arch }}-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.arch }}-${{ runner.os }}-yarn- | |
- name: 📦 Install dependencies | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: yarn install --frozen-lockfile | |
- name: ⚙️ Build application | |
run: yarn run build | |
- if: steps.yarn-cache.outputs.cache-hit != 'true' | |
name: 🗃 List the state of node modules | |
continue-on-error: true | |
run: yarn list | |
release: | |
name: 🔖 Release | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.event_name != 'merge_group' }} # skip this job if the event is a merge_group | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# used by semantic-release to bypass the branch protection rules | |
token: ${{ secrets.GH_TOKEN }} | |
- name: 🌐 Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: 🗂 Cache "node_modules" | |
uses: actions/cache@v3 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: "**/node_modules" | |
key: ${{ runner.arch }}-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.arch }}-${{ runner.os }}-yarn- | |
- name: 🔖 Release application | |
run: yarn run semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
id: version # save the version to use in an other step/job | |
outputs: | |
version: ${{ steps.version.outputs.nextVersion }} | |
push: | |
name: 🐳 Build and push image | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: 📥 Checkout repository | |
uses: actions/checkout@v4 | |
- name: ⚙️ Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: 🛠 Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: 📲 Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: 🐳 Build and push image [latest] | |
uses: docker/build-push-action@v5 | |
with: | |
context: . # https://github.com/marketplace/actions/build-and-push-docker-images#git-context | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest | |
- name: 🐳 Build and push image [${{ needs.release.outputs.version }}] | |
uses: docker/build-push-action@v5 | |
if: ${{ needs.release.outputs.version }} # deploy only if there is a new published version | |
with: | |
context: . # https://github.com/marketplace/actions/build-and-push-docker-images#git-context | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }} | |
deploy-pre-production: | |
name: 🚀 Deploy | |
if: ${{ github.actor != 'dependabot[bot]' }} && ${{ github.event_name != 'merge_group' }} | |
needs: [push, release] | |
uses: ./.github/workflows/reusable-kubernetes-deploy.yaml | |
with: | |
environment: pre-production | |
namespace: docs | |
deployment: docs-prep | |
image: docs | |
tag: ${{ needs.release.outputs.version || 'latest' }} | |
secrets: | |
kubeconfig: ${{ secrets.OCI_KUBE_CONFIG }} | |
registry_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
deploy-production: | |
name: 🚀 Deploy | |
if: ${{ github.event_name != 'pull_request' }} | |
needs: [push, release] | |
uses: ./.github/workflows/reusable-kubernetes-deploy.yaml | |
with: | |
environment: production | |
namespace: docs | |
deployment: docs-prod | |
image: docs | |
tag: ${{ needs.release.outputs.version || 'latest' }} | |
secrets: | |
kubeconfig: ${{ secrets.OCI_KUBE_CONFIG }} | |
registry_username: ${{ secrets.DOCKERHUB_USERNAME }} |