build-with-cli #128
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-with-cli | |
on: | |
push: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" # every day at midnight | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
packages: write # This is required to push to GitHub registry | |
jobs: | |
build_with_docker: | |
runs-on: ubuntu-latest | |
name: Build with Docker | |
env: | |
IMAGE_NAME: docker-django-example | |
IMAGE_REPO: ghcr.io/${{ github.repository_owner }} | |
VERSION: v0.0.1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# We are going to push to GH Container Registry | |
- name: Log in to GitHub registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
# Run Docker build with Buildkit driver | |
- name: Docker Build and Push | |
run: | | |
DOCKER_BUILDKIT=1 docker build . --tag $IMAGE_NAME | |
docker tag $IMAGE_NAME $IMAGE_REPO/$IMAGE_NAME:$VERSION | |
docker push $IMAGE_REPO/$IMAGE_NAME:$VERSION | |
build_with_nscloud: | |
runs-on: nscloud | |
name: Build with Namespace Cloud | |
env: | |
IMAGE_NAME: nsc-django-example | |
IMAGE_REPO: ghcr.io/${{ github.repository_owner }} | |
VERSION: v0.0.1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# We are going to push to GH Container Registry | |
- name: Log in to GitHub registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
# Install CLI and authenticate to Namespace Cloud | |
- name: Install and configure Namespace Cloud CLI | |
uses: namespacelabs/nscloud-setup@v0 | |
# Build and push with your Namespace Cloud workspace build cluster | |
- name: Build and push with Namespace Cloud cluster | |
run: | | |
nsc build . -t $IMAGE_REPO/$IMAGE_NAME:$VERSION --push | |
- uses: k0kubun/[email protected] | |
with: | |
payload: | | |
{ | |
"attachments": [{ | |
"title": "${{ github.repository }}: ${{ job.status }}: ${{ github.workflow }}", | |
"title_link": "https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks", | |
"text": "${{ github.repository }}@${{ github.ref }}: <https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>", | |
"fields": [{ "value": ${{ toJson(github.event.head_commit.message) }}, "short": false }], | |
"footer": "${{ github.event.head_commit.committer.name }} at ${{ github.event.head_commit.timestamp }}", | |
"color": "danger" | |
}] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
if: failure() && github.ref_name == 'main' |