feat: simplified version #1
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 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
permissions: | ||
id-token: write | ||
actions: read | ||
contents: read | ||
packages: write | ||
env: | ||
REGISTRY: ghcr.io | ||
BACKEND_IMAGE: aofg/backend | ||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
# Connect your workspace on nx.app and uncomment this to enable task distribution. | ||
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested | ||
# - run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci" | ||
# Cache node_modules | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
- run: npm ci | ||
- uses: nrwl/nx-set-shas@v4 | ||
- name: Login to GHCR | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- run: npx nx-cloud record -- nx format:check | ||
- run: INPUT_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} npx nx affected --base=$NX_BASE --head=$NX_HEAD -t lint build container | ||
- name: Set environment variables | ||
run: | | ||
HELM_SHORT=`echo "${{ github.event.repository.name }}" | cut -c -52` | ||
echo "HELM_SHORT=$HELM_SHORT" >> $GITHUB_ENV | ||
- name: Install doctl and Authorize to Digital Ocean | ||
uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
- name: Login to registry | ||
run: doctl registry login --expiry-seconds 3600 | ||
- name: Save DigitalOcean kubeconfig with short-lived credentials | ||
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.DIGITALOCEAN_K8S_CLUSTER_ID }} | ||
- name: Deploy | ||
if: github.ref == 'refs/heads/main' || matrix.namespace != 'production' | ||
run: | | ||
Check failure on line 69 in .github/workflows/build.yml GitHub Actions / buildInvalid workflow file
|
||
helm upgrade --install $HELM_SHORT ./.helm --namespace ${{ matrix.namespace }} --set image=${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE }}:sha-${{ NX_BASE }} --set branch=$GIT_BRANCH --dry-run | ||
helm upgrade --install $HELM_SHORT ./.helm --namespace ${{ matrix.namespace }} --set image=${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE }}:sha-${{ NX_BASE }} --set branch=$GIT_BRANCH --wait |