Skip to content

build-with-actions-no-context #107

build-with-actions-no-context

build-with-actions-no-context #107

name: build-with-actions-no-context
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: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Setup build driver to use Buildkit container
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Run standard Docker's build-push action
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.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: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Install CLI and authenticate to Namespace Cloud
- name: Install and configure Namespace Cloud CLI
uses: namespacelabs/nscloud-setup@v0
# Setup docker build to use your Namespace Cloud workspace build cluster
- name: Set up Namespace Cloud Buildx
uses: namespacelabs/nscloud-setup-buildx-action@v0
# Run Docker build-push action
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ env.IMAGE_REPO }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- 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'