Skip to content

Commit

Permalink
Add job to build docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed Nov 3, 2023
1 parent 839b887 commit 3777f73
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/docker_cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Cleanup Untagged Images

on:
# every sunday at 00:00
schedule:
- cron: "0 0 * * SUN"
# or manually
workflow_dispatch:

jobs:
delete-untagged-images:
name: Delete Untagged Images
runs-on: ubuntu-latest
steps:
- uses: bots-house/[email protected] # nosemgrep: yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha.third-party-action-not-pinned-to-commit-sha
with:
# NOTE: at now only orgs is supported
owner: airtai
name: test-chat-app

token: ${{ secrets.GITHUB_TOKEN }}
# Keep latest N untagged images
untagged-keep-latest: 1
42 changes: 42 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Pipeline
on: [push, workflow_dispatch]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PORT: ${{ vars.PORT }}
WASP_WEB_CLIENT_URL: ${{ vars.WASP_WEB_CLIENT_URL }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}

jobs:
docker_build_push:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install wasp
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: docker pull ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME || docker pull ghcr.io/$GITHUB_REPOSITORY || true
- run: docker build --build-arg PORT=$PORT -t ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME ./.wasp/build/
- name: Add tag latest if branch is main
if: github.ref_name == 'main'
run: docker tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME ghcr.io/$GITHUB_REPOSITORY:latest
- name: Push only if branch name is main
if: github.ref_name == 'main'
run: docker push ghcr.io/$GITHUB_REPOSITORY --all-tags

0 comments on commit 3777f73

Please sign in to comment.