build-and-push-ns-registry #105
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-and-push-ns-registry | |
on: | |
push: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" # every day at midnight | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read | |
jobs: | |
build_with_docker: | |
runs-on: ubuntu-latest | |
name: Build with Docker | |
env: | |
IMAGE_NAME: docker-django-example | |
VERSION: v0.0.1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Install CLI and authenticate to Namespace Cloud | |
- name: Install and configure Namespace Cloud CLI | |
id: nscloud # Needed to access its outputs | |
uses: namespacelabs/nscloud-setup@v0 | |
# 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: | |
context: . | |
push: true | |
tags: ${{ steps.nscloud.outputs.registry-address }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | |
build_with_nscloud: | |
runs-on: nscloud | |
name: Build with Namespace Cloud | |
env: | |
IMAGE_NAME: nsc-django-example | |
VERSION: v0.0.1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Install CLI and authenticate to Namespace Cloud | |
- name: Install and configure Namespace Cloud CLI | |
id: nscloud # Needed to access its outputs | |
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: | |
context: . | |
push: true | |
tags: ${{ steps.nscloud.outputs.registry-address }}/${{ 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' |