ci #230
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
name: ci | |
on: | |
schedule: | |
- cron: '36 7 2,12,22 * *' | |
create: {} | |
pull_request: | |
branches: [master] | |
push: | |
branches: [master, ci-test] | |
env: | |
DOCKER_REPO: 'sorah/acmesmith' | |
jobs: | |
test: | |
name: rspec | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby-version: ['3.0', '3.1', '3.2'] | |
container: | |
image: public.ecr.aws/sorah/ruby:${{ matrix.ruby-version }}-dev | |
steps: | |
- name: Cache bundled gems | |
uses: actions/cache@v1 | |
id: rspec-bundle | |
with: | |
path: ~/bundle | |
key: ${{ runner.os }}-${{ matrix.ruby-version }} | |
- uses: actions/checkout@master | |
- run: 'bundle install --path ~/bundle' | |
- run: 'bundle exec rspec -fd' | |
integration-pebble: | |
name: integration-pebble | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby-version: ['3.0', '3.1', '3.2'] | |
# FIXME: once GitHub Actions gains support of adding command line arguments to container | |
# services: | |
# # https://github.com/letsencrypt/pebble | |
# pebble: | |
# image: letsencrypt/pebble | |
# ports: | |
# - 14000:14000 # ACME port | |
# - 15000:15000 # Management port | |
# options: "pebble -config /test/config/pebble-config.json -strict -dnsserver 127.0.0.1:8053" | |
# | |
# challtestsrv: | |
# image: letsencrypt/pebble-challtestsrv:latest | |
# ports: | |
# - 8055:8055 # HTTP Management API | |
# - 8053:8053/udp # DNS | |
# - 8053:8053 # DNS | |
# options: 'pebble-challtestsrv -management :8055 -defaultIPv4 127.0.0.1' | |
steps: | |
- uses: actions/checkout@master | |
- name: Cache bundled gems | |
uses: actions/cache@v1 | |
id: instegration-pebble-bundle | |
with: | |
path: ~/bundle | |
key: ${{ runner.os }}-${{ matrix.ruby-version }} | |
- run: 'docker run -d --net=host --rm letsencrypt/pebble pebble -config /test/config/pebble-config.json -strict -dnsserver 127.0.0.1:8053' | |
- run: 'docker run -d --net=host --rm letsencrypt/pebble-challtestsrv pebble-challtestsrv -management :8055 -defaultIPv4 127.0.0.1' | |
- run: 'docker run --net=host -e CI --rm -v $(pwd):/work -v $(realpath ~/bundle):/bundle public.ecr.aws/sorah/ruby:${{ matrix.ruby-version }}-dev sh -c "cd /work && bundle install --path /bundle && bundle exec rspec -fd -t integration_pebble"' | |
docker-build: | |
name: docker-build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- run: 'echo $GITHUB_SHA > REVISION' | |
- run: "docker pull ${DOCKER_REPO}:latest || :" | |
- name: "docker tag ${DOCKER_REPO}:${TAG} ${DOCKER_REPO}:latest" | |
run: | | |
TAG=$(basename "${{ github.ref }}") | |
docker pull ${DOCKER_REPO}:${TAG} || : | |
docker tag ${DOCKER_REPO}:${TAG} ${DOCKER_REPO}:latest || : | |
if: "${{ startsWith(github.ref, 'refs/tags/v') }}" | |
- run: "docker pull ${DOCKER_REPO}:builder || :" | |
- run: "docker build --pull --cache-from ${DOCKER_REPO}:builder --target builder -t ${DOCKER_REPO}:builder -f Dockerfile ." | |
- run: "docker build --pull --cache-from ${DOCKER_REPO}:builder --cache-from ${DOCKER_REPO}:latest -t ${DOCKER_REPO}:${GITHUB_SHA} -f Dockerfile ." | |
- run: "echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u sorah --password-stdin" | |
if: "${{ github.event_name != 'pull_request' }}" | |
- run: "docker push ${DOCKER_REPO}:builder" | |
if: "${{ github.ref == 'refs/heads/master' }}" | |
- run: "docker push ${DOCKER_REPO}:${GITHUB_SHA}" | |
if: "${{ github.event_name != 'pull_request' }}" | |
docker-push: | |
name: docker-push | |
needs: [test, integration-pebble, docker-build] | |
if: "${{ github.event_name == 'push' || github.event_name == 'create' }}" | |
runs-on: ubuntu-latest | |
steps: | |
- run: "echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u sorah --password-stdin" | |
- run: "docker pull ${DOCKER_REPO}:${GITHUB_SHA}" | |
- run: | | |
docker tag ${DOCKER_REPO}:${GITHUB_SHA} ${DOCKER_REPO}:latest | |
docker push ${DOCKER_REPO}:latest | |
if: "${{ github.ref == 'refs/heads/master' }}" | |
- run: | | |
TAG=$(basename "${{ github.ref }}") | |
docker tag ${DOCKER_REPO}:${GITHUB_SHA} ${DOCKER_REPO}:${TAG} | |
docker push ${DOCKER_REPO}:${TAG} | |
if: "${{ startsWith(github.ref, 'refs/tags/v') }}" |