AtAuth
at main 71 lines 1.9 kB view raw
1name: Release 2 3on: 4 push: 5 tags: 6 - 'v*' 7 8env: 9 REGISTRY: ghcr.io 10 11permissions: 12 contents: read 13 packages: write 14 15jobs: 16 test: 17 name: Test 18 runs-on: ubuntu-latest 19 defaults: 20 run: 21 working-directory: gateway 22 steps: 23 - uses: actions/checkout@v4 24 - uses: actions/setup-node@v4 25 with: 26 node-version: '20' 27 - run: npm ci 28 - run: npm run typecheck 29 - run: npm run lint 30 - run: npm run test:run 31 32 build-and-push: 33 name: Build and Push Docker Image 34 runs-on: ubuntu-latest 35 needs: [test] 36 steps: 37 - uses: actions/checkout@v4 38 39 - name: Extract version from tag 40 id: meta 41 run: | 42 VERSION=${GITHUB_REF_NAME#v} 43 SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7) 44 IMAGE_NAME=$(echo "${{ github.repository_owner }}/atauth-gateway" | tr '[:upper:]' '[:lower:]') 45 echo "version=$VERSION" >> "$GITHUB_OUTPUT" 46 echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" 47 echo "image_name=$IMAGE_NAME" >> "$GITHUB_OUTPUT" 48 49 - name: Log in to GHCR 50 uses: docker/login-action@v3 51 with: 52 registry: ghcr.io 53 username: ${{ github.actor }} 54 password: ${{ secrets.GITHUB_TOKEN }} 55 56 - name: Set up Docker Buildx 57 uses: docker/setup-buildx-action@v3 58 59 - name: Build and push 60 uses: docker/build-push-action@v6 61 with: 62 context: ./gateway 63 platforms: linux/amd64,linux/arm64 64 push: true 65 build-args: | 66 BUILD_COMMIT=${{ steps.meta.outputs.short_sha }} 67 tags: | 68 ${{ env.REGISTRY }}/${{ steps.meta.outputs.image_name }}:${{ steps.meta.outputs.version }} 69 ${{ env.REGISTRY }}/${{ steps.meta.outputs.image_name }}:latest 70 cache-from: type=gha 71 cache-to: type=gha,mode=max