Fix gha smells

- Avoid incorrectly indented workflows
- Prevent running issue/PR actions on forks
- Define permissions for workflows with external actions
- Use commit hash instead of tags for action versions
This commit is contained in:
Cedric Willekens 2024-05-21 15:27:25 +02:00
parent f55f04ab4f
commit 99260cd47a
2 changed files with 10 additions and 13 deletions

View File

@ -10,18 +10,15 @@ jobs:
name: Push Docker image to Docker Hub name: Push Docker image to Docker Hub
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- - name: Check out the repo
name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- - name: Log in to Docker Hub
name: Log in to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- - name: Extract metadata (tags, labels) for Docker
name: Extract metadata (tags, labels) for Docker
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
@ -30,16 +27,13 @@ jobs:
type=raw,value=latest type=raw,value=latest
type=ref,event=tag type=ref,event=tag
- - name: Set up QEMU
name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v2
- - name: Set up Docker Buildx
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
- - name: Build and push Docker image
name: Build and push Docker image
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
context: . context: .

View File

@ -8,8 +8,11 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'ChatGPTNextWeb/ChatGPT-Next-Web'
permissions:
issues: write
steps: steps:
- uses: usthe/issues-translate-action@v2.7 - uses: usthe/issues-translate-action@b41f55ddc81d7d54bd542a4f289fe28ec081898e # v2.7
with: with:
IS_MODIFY_TITLE: false IS_MODIFY_TITLE: false
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically.