-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from appknox/gh-actions
Push to quay and ghcr
- Loading branch information
Showing
4 changed files
with
847 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,65 @@ | ||
name: Publish Docker image | ||
name: Publish docker image | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
GHCR_CONTAINER: ghcr.io/${{ github.repository }} | ||
QUAY_CONTAINER: quay.io/${{ github.repository }} | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to GitHub Container Registry | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
- name: Check out the repo | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get release version | ||
id: release | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
- name: Docker Login to ghcr | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker Login to quay | ||
uses: docker/[email protected] | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_GITHUB_ACTION_PUSH_USERNAME }} | ||
password: ${{ secrets.QUAY_GITHUB_ACTION_PUSH_PASSWORD }} | ||
|
||
- name: Get docker tag | ||
run: echo "::set-output name=docker_tag::${{ github.ref_name }}" | ||
id: docker_tag | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Download latest earthly | ||
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.6.2/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" | ||
- name: Earthly version | ||
run: earthly --version | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Run build and publish to ghcr | ||
run: earthly --ci --push +publish --TAG=${{ steps.docker_tag.outputs.docker_tag }} --CONTAINER=${{ env.GHCR_CONTAINER }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.APPKNOX_GITHUB_CONTAINER_TOKEN }} #encrypted secret var | ||
registry: ghcr.io | ||
- name: Run build and publish to quay | ||
run: earthly --ci --push +publish --TAG=${{ steps.docker_tag.outputs.docker_tag }} --CONTAINER=${{ env.QUAY_CONTAINER }} | ||
|
||
- name: Build & Push to GitHub Container Registry | ||
uses: docker/build-push-action@v2 | ||
- name: Slack notification | ||
if: always() | ||
uses: 8398a7/action-slack@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}:${{ steps.release.outputs.VERSION }} | ||
status: custom | ||
fields: repo,workflow | ||
custom_payload: | | ||
{ | ||
attachments: [{ | ||
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning', | ||
text: `Docker image creation ${{ job.status }}: ${{ env.GHCR_CONTAINER }}:${{ steps.docker_tag.outputs.docker_tag }} and ${{ env.QUAY_CONTAINER }}:${{ steps.docker_tag.outputs.docker_tag }}`, | ||
}] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
VERSION 0.6 | ||
|
||
ARG EARTHLY_GIT_BRANCH | ||
ARG EARTHLY_GIT_SHORT_HASH | ||
ARG TAG="$EARTHLY_GIT_BRANCH"_"$EARTHLY_GIT_SHORT_HASH" | ||
ARG CONTAINER="ghcr.io/appknox/stupid-socket" | ||
|
||
docker: | ||
FROM DOCKERFILE . | ||
SAVE IMAGE stupid-socket:"$TAG" | ||
|
||
publish: | ||
FROM DOCKERFILE . | ||
FROM +docker | ||
SAVE IMAGE --push "$CONTAINER":"$TAG" |
Oops, something went wrong.