From 921a5057879af273fe49572d49be4feb9eb86b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20R=C3=B6sch?= Date: Fri, 6 Sep 2024 15:39:16 +0200 Subject: [PATCH] Update GitHub actions to latest versions --- .github/workflows/docker.yml | 24 +++++++++++------------ .github/workflows/pages.yml | 37 +++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 47254a4e..1ca8dde8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,11 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Docker meta id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: | ghcr.io/${{ github.repository_owner }}/roshar-map @@ -27,45 +27,45 @@ jobs: type=semver,pattern={{major}} type=sha - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to GHCR - if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') - uses: docker/login-action@v1 + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == github.event.repository.default_branch) + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push release version - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . - push: ${{ github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') }} + push: ${{ github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == github.event.repository.default_branch) }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - name: Build and push dev version - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . file: Dockerfile-dev - push: ${{ github.ref == 'refs/heads/master' }} + push: ${{ github.ref == github.event.repository.default_branch }} tags: ghcr.io/${{ github.repository_owner }}/roshar-map:latest-dev labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - build_args: | + build-args: | PUBLIC_URL=${{ secrets.DOCKER_DEV_PUBLIC_URL }} update-service: runs-on: ubuntu-latest needs: [build] - if: github.event_name == 'push' && github.ref == 'refs/heads/master' && (contains(github.event.head_commit.message, '[deploy-dev]') || contains(github.event.head_commit.message, '[deploy]')) + if: github.event_name == 'push' && github.ref == github.event.repository.default_branch && (contains(github.event.head_commit.message, '[deploy-dev]') || contains(github.event.head_commit.message, '[deploy]')) steps: - name: Setup SSH Keys and known_hosts diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index ae9cf7d6..a9355ab8 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -14,17 +14,16 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: '14' - name: Cache node modules - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: node_modules key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} @@ -48,11 +47,27 @@ jobs: env: FILE_NAME: "./dist/release/CNAME" FILE_DATA: "roshar.17thshard.com" + - name: Upload artifact + uses: actions/upload-pages-artifact@v3.0.1 + with: + path: 'dist/release' - - name: Deploy - uses: maxheld83/ghpages@v0.2.1 - if: (github.event_name == 'push' && github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, '[deploy]')) - || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy) - env: - GH_PAT: ${{ secrets.GH_PAT }} - BUILD_DIR: dist/release/ + deploy: + if: (github.event_name == 'push' && github.ref == github.event.repository.default_branch && contains(github.event.head_commit.message, '[deploy]')) + || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy) + + needs: build + + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4