diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 751c958..11c0ec2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,18 +15,16 @@ permissions: contents: read 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 @@ -34,17 +32,23 @@ jobs: - 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: @@ -69,20 +73,38 @@ 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" - 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 - - # deploy static + - name: Deploy to GitHub Releases + run: | + 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: + concurrency: ci-${{ github.ref }} environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} diff --git a/README.md b/README.md index a7e25f6..5d3f52e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 \