Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update workflows #41

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name: Code Quality Checks

on: pull_request
on: [pull_request_target]

jobs:
build:
runs-on: ubuntu-latest
name: Code Quality Checks
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v4
with:
python-version: 3.9.13
Expand Down
66 changes: 25 additions & 41 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
name: Container Processing

on:
on:
push:
pull_request:
branches: [ "main" ]

jobs:
build:
push_to_registry:
name: Push Docker image to DockerHub
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Get tag
id: get_tag
run: |
echo "::set-output name=IMAGE_TAG::$(echo $GITHUB_REF | cut -d / -f 3)"

- name: Set up qemu
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login --username "${{ vars.DOCKER_USERNAME }}" --password-stdin
- name: Set DOCKER_FOLDER
run: echo "DOCKER_FOLDER=$(echo ${{ github.event.repository.name }} | sed 's/edgetech-//')" >> $GITHUB_ENV

- name: Get changes
id: identify
uses: jitterbit/get-changed-files@v1
- run: |
echo ${{ steps.files.output.all }}

- name: Build image
env:
GITHUB_REPOSITORY: ${{ github.repository }}
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
DOCKER_FOLDER: "daisy"
DOCKER_NAMESPACE: ${{ vars.DOCKER_NAMESPACE }}
TAG_NAME: ${{ steps.get_tag.outputs.IMAGE_TAG }}
run: |
GITHUB_REPO=$(basename $GITHUB_REPOSITORY)
docker buildx build $DOCKER_FOLDER \
--platform linux/arm64,linux/amd64 \
--push \
--tag $DOCKER_NAMESPACE/$GITHUB_REPO:latest \
--tag $DOCKER_NAMESPACE/$GITHUB_REPO:$TAG_NAME
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_FOLDER }}
platforms: linux/arm64,linux/amd64
push: true
tags: ${{ vars.DOCKER_NAMESPACE }}/${{ github.event.repository.name }}:latest
17 changes: 17 additions & 0 deletions .github/workflows/docker-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Untag PR Docker Image

on:
pull_request:
types:
- closed

jobs:
untag-image:
name: Untag PR Docker Image from Dockerhub
runs-on: ubuntu-latest

steps:
- name: Untag Docker image on DockerHub
run: |
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "${{ vars.DOCKER_USERNAME }}", "password": "${{ secrets.DOCKER_TOKEN }}"}' "https://hub.docker.com/v2/users/login/" | jq -r .token)
curl "https://hub.docker.com/v2/repositories/${{ vars.DOCKER_NAMESPACE }}/${{ github.event.repository.name }}/tags/testing-PR${{ github.event.pull_request.number }}" -X DELETE -H "Authorization: JWT $TOKEN"
38 changes: 38 additions & 0 deletions .github/workflows/docker-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker Build Testing

on: [pull_request_target]



jobs:
push_to_registry:
name: Test Docker Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Set DOCKER_FOLDER
run: echo "DOCKER_FOLDER=$(echo ${{ github.event.repository.name }} | sed 's/edgetech-//')" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_FOLDER }}
platforms: linux/arm64,linux/amd64
push: true
tags: ${{ vars.DOCKER_NAMESPACE }}/${{ github.event.repository.name }}:testing-PR${{ github.event.pull_request.number }}
49 changes: 27 additions & 22 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,34 @@ on:
types: [ "published" ]

jobs:
tag-remote:
push_to_registry:
name: Dockerhub Release
runs-on: ubuntu-latest
steps:
- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login --username "${{ vars.DOCKER_USERNAME }}" --password-stdin
- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Build image
env:
GITHUB_REPOSITORY: ${{ github.repository }}
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
DOCKER_FOLDER: "daisy"
DOCKER_NAMESPACE: ${{ vars.DOCKER_NAMESPACE }}
RELEASE_NAME: ${{ github.event.release.name }}
run: |
GITHUB_REPO=$(basename $GITHUB_REPOSITORY)
docker buildx build $DOCKER_FOLDER \
--platform linux/arm64,linux/amd64 \
--push \
--tag $DOCKER_NAMESPACE/$GITHUB_REPO:latest \
--tag $DOCKER_NAMESPACE/$GITHUB_REPO:$RELEASE_NAME
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Set DOCKER_FOLDER
run: echo "DOCKER_FOLDER=$(echo ${{ github.event.repository.name }} | sed 's/edgetech-//')" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_FOLDER }}
platforms: linux/arm64,linux/amd64
push: true
tags: |
${{ vars.DOCKER_NAMESPACE }}/${{ github.event.repository.name }}:${{ github.event.release.name }}
${{ vars.DOCKER_NAMESPACE }}/${{ github.event.repository.name }}:stable