Skip to content

Commit

Permalink
Restrict workflow permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
AsamK committed Dec 4, 2022
1 parent 44c945f commit 47feda6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
pull_request:
workflow_call:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build:

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
schedule:
- cron: '0 7 * * 4'

permissions:
contents: read # to fetch code (actions/checkout)
security-events: write

jobs:
analyse:
name: Analyse
Expand Down
68 changes: 11 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- v*

permissions:
contents: read # to fetch code (actions/checkout)

env:
IMAGE_NAME: signal-cli
IMAGE_REGISTRY: ghcr.io/asamk
Expand All @@ -20,6 +23,8 @@ jobs:
lib_to_jar:
needs: ci_wf
runs-on: ubuntu-latest
permissions:
contents: write

outputs:
signal_cli_version: ${{ steps.cli_ver.outputs.version }}
Expand Down Expand Up @@ -141,66 +146,12 @@ jobs:
asset_name: signal-cli-${{ steps.cli_ver.outputs.version }}-macOS.tar.gz
asset_content_type: application/x-compressed-tar # .tar.gz


run_repackaged:

needs:
- lib_to_jar

strategy:
matrix:
runner:
- windows-latest
- macos-latest

runs-on: ${{ matrix.runner }}

defaults:
run:
shell: bash # Explicit for windows

env:
JAVA_VERSION: 19

steps:

- name: Download the release file
env:
SIGNAL_CLI_VER: ${{ needs.lib_to_jar.outputs.signal_cli_version }}
RELEASE_ID: ${{ needs.lib_to_jar.outputs.release_id }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
file_name=signal-cli-${SIGNAL_CLI_VER}-${RUNNER_OS}.tar.gz
echo "$file_name"
assets_json=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets")
asset_dl_url=$(echo "$assets_json" | jq -r ".[] | select (.name == \"$file_name\") | .url")
echo "$asset_dl_url"
curl -sLOJ \
-H 'Accept: application/octet-stream' \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"$asset_dl_url"
tar -xzf "$file_name"
- name: Set up JDK for running signal-cli executable
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ env.JAVA_VERSION }}
java-package: 'jre'

- name: Run signal-cli
run: |
cd signal-cli-*/bin
if [[ "$RUNNER_OS" == 'Windows' ]]; then
EXECUTABLE_SUFFIX=".bat"
fi
./signal-cli${EXECUTABLE_SUFFIX} listAccounts
build-container:
needs: ci_wf
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -248,6 +199,9 @@ jobs:
build-container-native:
needs: ci_wf
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit 47feda6

Please sign in to comment.