Use granular permissions for GitHub Actions

This commit is contained in:
Tyrrrz 2023-05-27 22:42:04 +03:00
parent 03784f0d7c
commit 2b7f1ed4ed
2 changed files with 21 additions and 4 deletions

View file

@ -5,6 +5,9 @@ on: [push, pull_request]
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps: steps:
- name: Checkout - name: Checkout
@ -30,6 +33,8 @@ jobs:
deploy-latest: deploy-latest:
if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master' }} if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
steps: steps:
- name: Checkout - name: Checkout
@ -55,6 +60,8 @@ jobs:
deploy-stable: deploy-stable:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
steps: steps:
- name: Checkout - name: Checkout
@ -80,4 +87,4 @@ jobs:
--push --push
--tag tyrrrz/discordchatexporter:stable --tag tyrrrz/discordchatexporter:stable
--tag tyrrrz/discordchatexporter:${{ steps.get-version.outputs.tag }} --tag tyrrrz/discordchatexporter:${{ steps.get-version.outputs.tag }}
. .

View file

@ -5,6 +5,8 @@ on: [push, pull_request]
jobs: jobs:
test: test:
runs-on: windows-latest runs-on: windows-latest
permissions:
contents: read
env: env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
@ -38,9 +40,12 @@ jobs:
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
package: pack:
needs: test needs: test
runs-on: windows-latest runs-on: windows-latest
permissions:
actions: write
contents: read
env: env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
@ -82,8 +87,11 @@ jobs:
deploy: deploy:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
needs: package needs: pack
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
actions: read
contents: write
steps: steps:
- name: Download artifacts (CLI) - name: Download artifacts (CLI)
@ -128,6 +136,8 @@ jobs:
notify: notify:
needs: deploy needs: deploy
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
steps: steps:
- name: Get release version - name: Get release version
@ -144,4 +154,4 @@ jobs:
body: | body: |
{ {
"content": "**DiscordChatExporter** new version released!\nVersion: `${{ steps.get-version.outputs.tag }}`\nChangelog: <https://github.com/Tyrrrz/DiscordChatExporter/blob/${{ steps.get-version.outputs.tag }}/Changelog.md>" "content": "**DiscordChatExporter** new version released!\nVersion: `${{ steps.get-version.outputs.tag }}`\nChangelog: <https://github.com/Tyrrrz/DiscordChatExporter/blob/${{ steps.get-version.outputs.tag }}/Changelog.md>"
} }