Skip to content

Commit

Permalink
Workflow: Release on new tag, dependency version updates
Browse files Browse the repository at this point in the history
  • Loading branch information
klo2k committed Nov 16, 2023
1 parent 3946b86 commit a627a96
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 15 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/deploy_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,44 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Enable docker cache to speed-up builds
- name: Setup Docker build cache
uses: actions/cache@v3
with:
path: /tmp/buildx-cache
key: ${{runner.os}}-buildx-${{github.sha}}
restore-keys: |
${{runner.os}}-buildx-
# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: crazy-max/[email protected]
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Docker login
run: docker login --username '${{secrets.REGISTRY_USERNAME}}' --password '${{secrets.REGISTRY_ACCESS_TOKEN}}'
uses: docker/login-action@v3
with:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_ACCESS_TOKEN}}

- name: Build + Push image ("development")
env:
# `github.ref_name` == git tag triggered build
IMAGE_VERSION: ${{github.ref_name}}
run: |
docker buildx build \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${IMAGE_VERSION}" \
--platform "linux/amd64,linux/arm/v7,linux/arm64" \
--tag "${{secrets.REGISTRY_USERNAME}}/openconnect:development" \
--output "type=image,push=true" \
Expand Down
70 changes: 61 additions & 9 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,88 @@
name: Deploy Release Build

# Trigger on release
# Trigger on new version tag
on:
release:
types:
- released
push:
tags:
- '[0-9]+.[0-9]+*'

jobs:
build_deploy_to_registry:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Enable docker cache to speed-up builds
- name: Setup Docker build cache
uses: actions/cache@v3
with:
path: /tmp/buildx-cache
key: ${{runner.os}}-buildx-${{github.sha}}
restore-keys: |
${{runner.os}}-buildx-
# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: crazy-max/[email protected]
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Docker login
run: docker login --username '${{secrets.REGISTRY_USERNAME}}' --password '${{secrets.REGISTRY_ACCESS_TOKEN}}'
uses: docker/login-action@v3
with:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_ACCESS_TOKEN}}

- name: Build + Push image (tag = git release tag)
- name: Build + Push image (tag = git tag)
env:
# `github.ref_name` == git tag triggered build
IMAGE_VERSION: ${{github.ref_name}}
run: |
docker buildx build \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${IMAGE_VERSION}" \
--platform "linux/amd64,linux/arm/v7,linux/arm64" \
--tag "${{secrets.REGISTRY_USERNAME}}/openconnect:${GITHUB_REF#refs/tags/}" \
--pull
--tag "${{secrets.REGISTRY_USERNAME}}/openconnect:${IMAGE_VERSION}" \
--output "type=image,push=true" \
--file ./Dockerfile .
- name: Build + Push image ("latest")
env:
# `github.ref_name` == git tag triggered build
IMAGE_VERSION: ${{github.ref_name}}
run: |
docker buildx build \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="${IMAGE_VERSION}" \
--platform "linux/amd64,linux/arm/v7,linux/arm64" \
--tag "${{secrets.REGISTRY_USERNAME}}/openconnect:latest" \
--output "type=image,push=true" \
--file ./Dockerfile .
create_release:
runs-on: ubuntu-latest
permissions:
contents: write
needs: build_deploy_to_registry
steps:
- name: Create Github Release
uses: ncipollo/[email protected]
with:
tag: ${{github.ref_name}}
name: ${{github.ref_name}}
body: (Automated release)
draft: false
prerelease: false
# Allow re-run workflow job
skipIfReleaseExists: true
17 changes: 14 additions & 3 deletions .github/workflows/validate_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Enable multi-architecture support on build node
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@master
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Build image (no push)
run: |
docker buildx build \
--platform "linux/amd64,linux/arm/v7,linux/arm64" \
--label org.opencontainers.image.revision="${{github.sha}}" \
--label org.opencontainers.image.version="-" \
--platform "linux/arm/v7,linux/arm64" \
--pull \
--output "type=image,push=false" \
--file ./Dockerfile .

0 comments on commit a627a96

Please sign in to comment.