diff --git a/.editorconfig b/.editorconfig index 6773ee4..5e16f8e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,3 +8,10 @@ insert_final_newline = true indent_style = tab indent_size = 4 max_line_length = 120 + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 4fb7779..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: moq.js - -on: - pull_request: - branches: ["main"] - -jobs: - check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - - - run: npm ci - - run: npm run build - - run: npm run lint diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..916828f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,54 @@ +name: main + +on: + push: + branches: ["main"] + +env: + REGISTRY: docker.io + IMAGE: ${{ github.repository }} + SERVICE: web + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + id-token: write + + # Only one release at a time and cancel prior releases + concurrency: + group: release + cancel-in-progress: true + + steps: + - uses: actions/checkout@v3 + + # I'm paying for Depot for faster ARM builds. + - uses: depot/setup-action@v1 + + # Log into the docker registry via the GCP token + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # Build and push Docker image with Depot + - uses: depot/build-push-action@v1 + with: + project: hppp3x0qjc + context: . + push: true + tags: ${{env.REGISTRY}}/${{env.IMAGE}} + + # Log in to GCP + - uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} + + # Deploy to cloud run + - uses: google-github-actions/deploy-cloudrun@v1 + with: + service: ${{env.SERVICE}} + image: ${{env.REGISTRY}}/${{env.IMAGE}} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..d285322 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,17 @@ +name: pr + +on: + pull_request: + branches: ["main"] + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + + - run: npm ci + - run: npm run build + - run: npm run lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a384851..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Release Docker Image - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -on: - push: - branches: ["main"] - -env: - REGISTRY: us-central1-docker.pkg.dev - IMAGE: quic-video/deploy/moq-js:latest - SERVICE: web - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - # Only one release at a time and cancel prior releases - concurrency: - group: release - cancel-in-progress: true - - steps: - - name: Checkout - uses: actions/checkout@v3 - - # I'm paying for Depot for faster ARM builds. - - name: Setup depot - uses: depot/setup-action@v1 - - # Log in to GCP - - id: auth - name: Authenticate to Google Cloud - uses: google-github-actions/auth@v1 - with: - token_format: access_token - credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} - - # This example uses the docker login action - - uses: docker/login-action@v1 - with: - registry: ${{ env.REGISTRY }} - username: oauth2accesstoken - password: ${{ steps.auth.outputs.access_token }} - - # This example runs "docker login" directly to Artifact Registry. - - run: |- - echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://${{ENV.REGISTRY}} - - # Build and push Docker image with Depot - - name: Build and push Docker image - uses: depot/build-push-action@v1 - with: - project: hppp3x0qjc - context: . - push: true - tags: ${{env.REGISTRY}}/${{env.IMAGE}} - - # Deploy to cloud run - - name: Update Cloud Run - uses: google-github-actions/deploy-cloudrun@v1 - with: - service: ${{env.SERVICE}} - image: ${{env.REGISTRY}}/${{env.IMAGE}}