Skip to content

Commit 6be0038

Browse files
committed
Merge updated and tested action
Signed-off-by: Aaron Wislang <aaron.wislang@microsoft.com>
1 parent 528fd09 commit 6be0038

3 files changed

Lines changed: 16 additions & 55 deletions

File tree

.github/workflows/publish.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ jobs:
2020
- name: Checkout repository
2121
uses: actions/checkout@v2
2222

23+
- name: Login to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
2330
- name: Cache cargo bin
2431
id: cache-cargo
2532
uses: actions/cache@v3
@@ -42,6 +49,4 @@ jobs:
4249
run: bash scripts/build.sh
4350

4451
- name: Run publish script
45-
env:
46-
GH_TOKEN: ${{ github.token }}
4752
run: bash scripts/publish.sh

.github/workflows/test.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

scripts/publish.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#!/bin/bash
22

3-
# login to the registry
4-
# if running locally, we may need to:
5-
# gh auth refresh -h github.com -s write:packages,read:packages
6-
gh auth token | docker login ghcr.io --username YOURUSERNAME --password-stdin
7-
8-
# publish using wkg
9-
PROJECT_NAME="rust_wasi_hello"
10-
11-
if [ -z "$IMAGE_NAME" ]; then
12-
GH_USER=$(gh api user --jq '.login')
13-
IMAGE_NAME="${GH_USER}/rust-wasi-hello"
14-
export IMAGE_NAME
3+
# not running in github actions? use gh cli to login, etc, locally
4+
if [ "$GITHUB_ACTIONS" != "true" ]; then
5+
# login to the registry
6+
# if running locally, we may need to:
7+
# gh auth refresh -h github.com -s write:packages,read:packages
8+
gh auth token | docker login ghcr.io --username YOURUSERNAME --password-stdin
9+
GH_USER=$(gh api user --jq '.login')
10+
IMAGE_NAME="${GH_USER}/rust-wasi-hello"
1511
fi
1612

13+
PROJECT_NAME="rust_wasi_hello"
1714
REGISTRY_REFERENCE="ghcr.io/${IMAGE_NAME}:latest"
1815

1916
wkg oci push $REGISTRY_REFERENCE target/wasm32-wasip1/release/$PROJECT_NAME.wasm

0 commit comments

Comments
 (0)