Skip to content

Commit

Permalink
Fix deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jan 2, 2024
1 parent 1f676fb commit 05707f8
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 26 deletions.
86 changes: 63 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,43 @@ on:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
contents: write
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
packages: write

jobs:
# deploy docker to github registry
deployDocker:
if: github.event_name == 'release'
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Packages
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: ./Dockerfile
push: true
tags: docker.pkg.github.com/${{ github.repository }}/anser-static:${{ github.sha }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# deploy static
deployStatic:
Expand All @@ -69,20 +73,58 @@ jobs:
if: github.event_name == 'release'
run: |
cd dist
zip -r ../anser-static-deploy.zip www
zip -r ../anser-static-deploy.zip .
cd ..
- name: "Upload to github releases"
- name: Deploy to release branch
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./anser-static-deploy.zip
asset_name: anser-static-deploy.zip
asset_content_type: application/zip
run: |
# Commit the changes
git config --global user.name "Github Actions"
git config --global user.email "[email protected]"
# deploy static
git clone --single-branch --branch "releases" [email protected]:${{ github.repository }} releases
cd releases
mkdir -p ${{ github.ref_name }}
cp ../dist/lib/liquidwallet.lib.js ${{ github.ref_name }}
git add .
git commit -m "update ${{ github.ref_name }}"
git push origin releases
- name: Deploy to GitHub Releases
if: github.event_name == 'release'
run: |
set -e
echo "${GITHUB_EVENT_PATH}"
cat ${GITHUB_EVENT_PATH}
releaseId=$(jq --raw-output '.release.id' ${GITHUB_EVENT_PATH})
echo "Upload to release $releaseId"
filename="./anser-static-deploy.zip"
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId/assets?name=$(basename $filename)"
echo "Upload to $url"
curl -L \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/zip" \
--data-binary @"$filename" \
"$url"
filename="./dist/lib/liquidwallet.lib.js"
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId/assets?name=$(basename $filename)"
echo "Upload to $url"
curl -L \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/javascript" \
--data-binary @"$filename" \
"$url"
# deploy gh pages
deployPages:
if: github.event_name == 'release'
concurrency: ci-${{ github.ref }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand All @@ -99,12 +141,10 @@ jobs:
bash build.sh
- name: Upload artifact
if: github.event_name == 'release'
uses: actions/upload-pages-artifact@v3
with:
path: "./dist/"

- name: Deploy to GitHub Pages
if: github.event_name == 'release'
id: deployment
uses: actions/deploy-pages@v4
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ Anser is a web app that can be hosted on any web server capable of serving stati
Anser is also available as a self-contained docker container that can be run on any docker host. You can build a docker image from this repo (see [Build and run with Docker](#build-and-run-with-docker)) or you can pull the latest image from github package registry.

```bash
TODO
# Pull the image ( check https://github.com/riccardobl/anser-liquid/pkgs/container/anser-liquid for the latest version )
docker pull ghcr.io/riccardobl/anser-liquid:v1.0

# Run and expose on port 8080
docker run -d \
--restart=always \
--name="anserliquid" \
--read-only \
--tmpfs /data \
--tmpfs /tmp \
--tmpfs /config \
-p 8080:80 \
ghcr.io/riccardobl/anser-liquid:v1.0

```

# Development
Expand Down Expand Up @@ -102,8 +115,7 @@ cd anser-liquid
docker build -t anserliquid .

# Run and expose on port 8080
docker run -d \
--restart=always \
docker run -it --rm \
--name="anserliquid" \
--read-only \
--tmpfs /data \
Expand Down

0 comments on commit 05707f8

Please sign in to comment.