2019-12-06 15:49:30 +00:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
2020-11-05 13:11:59 +00:00
|
|
|
schedule:
|
|
|
|
- cron: '0 5 * * *' # everyday at 5 am UTC
|
2019-12-06 15:49:30 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2020-11-05 13:11:59 +00:00
|
|
|
tags:
|
|
|
|
- v[0-9]+.[0-9]+.[0-9]+
|
2019-12-06 15:49:30 +00:00
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Build
|
|
|
|
runs-on: ubuntu-16.04
|
|
|
|
env:
|
2019-12-08 19:41:28 +00:00
|
|
|
GOFLAGS: -mod=readonly
|
2019-12-06 15:49:30 +00:00
|
|
|
|
|
|
|
services:
|
|
|
|
postgres:
|
|
|
|
image: postgres:10.8
|
|
|
|
ports:
|
|
|
|
- 5432
|
|
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
|
|
|
2020-03-18 10:04:42 +00:00
|
|
|
mysql:
|
|
|
|
image: mysql:5.7
|
|
|
|
env:
|
|
|
|
MYSQL_ROOT_PASSWORD: root
|
|
|
|
MYSQL_DATABASE: dex
|
|
|
|
ports:
|
|
|
|
- 3306:3306
|
|
|
|
options: --health-cmd "mysql -proot -e \"show databases;\"" --health-interval 10s --health-timeout 5s --health-retries 5
|
|
|
|
|
2019-12-06 15:49:30 +00:00
|
|
|
etcd:
|
|
|
|
image: gcr.io/etcd-development/etcd:v3.2.9
|
|
|
|
ports:
|
|
|
|
- 2379
|
|
|
|
env:
|
|
|
|
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
|
|
|
|
ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379
|
|
|
|
options: --health-cmd "ETCDCTL_API=3 etcdctl --endpoints http://localhost:2379 endpoint health" --health-interval 10s --health-timeout 5s --health-retries 5
|
|
|
|
|
|
|
|
keystone:
|
|
|
|
image: openio/openstack-keystone:pike
|
|
|
|
ports:
|
|
|
|
- 5000
|
|
|
|
- 35357
|
|
|
|
options: --health-cmd "curl --fail http://localhost:5000/v3" --health-interval 10s --health-timeout 5s --health-retries 5
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v1
|
|
|
|
with:
|
2020-09-27 22:10:45 +00:00
|
|
|
go-version: 1.15
|
2019-12-06 15:49:30 +00:00
|
|
|
|
|
|
|
- name: Checkout code
|
2020-02-21 14:53:13 +00:00
|
|
|
uses: actions/checkout@v2
|
2019-12-06 15:49:30 +00:00
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: make testall
|
|
|
|
env:
|
2019-12-14 01:25:56 +00:00
|
|
|
DEX_FOO_USER_PASSWORD: $2a$10$33EMT0cVYVlPy6WAMCLsceLYjWhuHpbz5yuZxu/GAFj03J9Lytjuy
|
2019-12-06 15:49:30 +00:00
|
|
|
DEX_MYSQL_DATABASE: dex
|
|
|
|
DEX_MYSQL_USER: root
|
|
|
|
DEX_MYSQL_PASSWORD: root
|
|
|
|
DEX_MYSQL_HOST: 127.0.0.1
|
|
|
|
DEX_MYSQL_PORT: 3306
|
|
|
|
DEX_POSTGRES_DATABASE: postgres
|
|
|
|
DEX_POSTGRES_USER: postgres
|
|
|
|
DEX_POSTGRES_PASSWORD: postgres
|
|
|
|
DEX_POSTGRES_HOST: localhost
|
|
|
|
DEX_POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
|
|
|
DEX_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports[2379] }}
|
2019-12-08 19:22:09 +00:00
|
|
|
DEX_LDAP_TESTS: 1
|
2019-12-06 15:49:30 +00:00
|
|
|
DEX_KEYSTONE_URL: http://localhost:${{ job.services.keystone.ports[5000] }}
|
|
|
|
DEX_KEYSTONE_ADMIN_URL: http://localhost:${{ job.services.keystone.ports[35357] }}
|
|
|
|
DEX_KEYSTONE_ADMIN_USER: demo
|
|
|
|
DEX_KEYSTONE_ADMIN_PASS: DEMO_PASS
|
|
|
|
|
2019-12-18 13:55:52 +00:00
|
|
|
- name: Run linter
|
|
|
|
run: make lint
|
2019-12-06 15:49:30 +00:00
|
|
|
|
|
|
|
# Ensure proto generation doesn't depend on external packages.
|
|
|
|
- name: Verify proto
|
|
|
|
run: make verify-proto
|
2020-07-01 11:03:41 +00:00
|
|
|
|
|
|
|
docker:
|
|
|
|
name: Docker
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2020-11-05 13:11:59 +00:00
|
|
|
- name: Checkout
|
2020-07-01 11:03:41 +00:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2020-11-05 13:11:59 +00:00
|
|
|
- name: Calculate Docker image tags
|
|
|
|
id: tags
|
|
|
|
env:
|
|
|
|
DOCKER_IMAGES: "ghcr.io/dexidp/dex dexidp/dex"
|
2020-09-27 21:47:39 +00:00
|
|
|
run: |
|
2020-11-05 13:11:59 +00:00
|
|
|
VERSION=noop
|
|
|
|
|
|
|
|
if [[ "${{ github.event_name }}" == "schedule" ]]; then
|
|
|
|
VERSION=nightly
|
|
|
|
else
|
|
|
|
case $GITHUB_REF in
|
|
|
|
refs/tags/*) VERSION=${GITHUB_REF#refs/tags/};;
|
|
|
|
refs/heads/*) VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g');;
|
|
|
|
refs/pull/*) VERSION=pr-${{ github.event.number }};;
|
|
|
|
*) VERSION=sha-${GITHUB_SHA::8};;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
TAGS=()
|
|
|
|
for image in $DOCKER_IMAGES; do
|
|
|
|
TAGS+=("${image}:${VERSION}")
|
|
|
|
|
|
|
|
if [[ "${{ github.event.repository.default_branch }}" == "$VERSION" ]]; then
|
|
|
|
TAGS+=("${image}:latest")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ::set-output name=version::${VERSION}
|
|
|
|
echo ::set-output name=tags::$(IFS=,; echo "${TAGS[*]}")
|
|
|
|
echo ::set-output name=commit_hash::${GITHUB_SHA::8}
|
|
|
|
echo ::set-output name=build_date::$(git show -s --format=%cI)
|
2020-09-27 21:47:39 +00:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
install: true
|
|
|
|
version: latest
|
|
|
|
# TODO: Remove driver-opts once fix is released docker/buildx#386
|
|
|
|
driver-opts: image=moby/buildkit:master
|
|
|
|
|
2020-11-05 13:11:59 +00:00
|
|
|
- name: Login to GitHub Container Registry
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.CR_PAT }}
|
|
|
|
if: github.event_name == 'push'
|
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
2020-09-27 21:47:39 +00:00
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
2020-09-27 21:56:02 +00:00
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2020-10-04 13:01:45 +00:00
|
|
|
if: github.event_name == 'push'
|
2020-07-01 11:03:41 +00:00
|
|
|
|
2020-11-05 13:11:59 +00:00
|
|
|
- name: Build and push
|
2020-09-27 21:47:39 +00:00
|
|
|
uses: docker/build-push-action@v2
|
2020-07-01 11:03:41 +00:00
|
|
|
with:
|
2020-09-27 21:47:39 +00:00
|
|
|
context: .
|
|
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
2020-07-01 11:03:41 +00:00
|
|
|
push: ${{ github.event_name == 'push' }}
|
2020-11-05 13:11:59 +00:00
|
|
|
tags: ${{ steps.tags.outputs.tags }}
|
|
|
|
build-args: |
|
|
|
|
VERSION=${{ steps.tags.outputs.version }}
|
|
|
|
COMMIT_HASH=${{ steps.tags.outputs.commit_hash }}
|
|
|
|
BUILD_DATE=${{ steps.tags.outputs.build_date }}
|
2020-09-27 21:47:39 +00:00
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.title=${{ github.event.repository.name }}
|
|
|
|
org.opencontainers.image.description=${{ github.event.repository.description }}
|
|
|
|
org.opencontainers.image.url=${{ github.event.repository.html_url }}
|
|
|
|
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
|
2020-11-05 13:11:59 +00:00
|
|
|
org.opencontainers.image.version=${{ steps.tags.outputs.version }}
|
|
|
|
org.opencontainers.image.created=${{ steps.tags.outputs.build_date }}
|
2020-09-27 21:47:39 +00:00
|
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
|
|
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
|
2020-11-05 13:11:59 +00:00
|
|
|
org.opencontainers.image.documentation=https://dexidp.io/docs/
|