From 91ac5ee25e895460504bb1f4430ae6161cf70e6c Mon Sep 17 00:00:00 2001 From: Carl Reid Date: Fri, 19 Nov 2021 20:26:26 +0100 Subject: [PATCH 1/2] Deploy container to registry --- .github/workflows/container-build.yml | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/container-build.yml diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml new file mode 100644 index 00000000..b4a709ca --- /dev/null +++ b/.github/workflows/container-build.yml @@ -0,0 +1,50 @@ +name: Build & Deploy Container + +on: + push: + branches: + - master + tags: + - 'v*' + workflow_dispatch: {} + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Log in to Github Container Registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 2246eff4c1e4756302f5477d51cc3ebdce030c7a Mon Sep 17 00:00:00 2001 From: Carl Reid Date: Fri, 19 Nov 2021 20:43:14 +0100 Subject: [PATCH 2/2] Use image from Github Container Registry This avoids consumers from needing to wait for Dockerfile to build every run --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4ddd4966..824826e3 100644 --- a/action.yml +++ b/action.yml @@ -26,7 +26,7 @@ inputs: default: ${{ github.event_name }} runs: using: docker - image: Dockerfile + image: 'docker://ghcr.io/stoplightio/spectral-action:0.8.3' branding: icon: code color: yellow