Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #23 from CSCfi/refactor/gh-actions
Browse files Browse the repository at this point in the history
refactor gh actions
  • Loading branch information
blankdots authored Nov 4, 2020
2 parents 3dc82cf + e010111 commit 92183c6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 28 deletions.
70 changes: 46 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,49 @@ jobs:
name: Push swift-sharing-request Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Login to DockerHub Registry
run: echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin
- name: Get the version
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
- name: Build the tagged Docker image
if: ${{ steps.vars.outputs.tag != '/master' && steps.vars.outputs.tag != '/devel' }}
run: docker build . --file Dockerfile --tag cscfi/swift-sharing-request:${{steps.vars.outputs.tag}}
- name: Push the tagged Docker image
if: ${{ steps.vars.outputs.tag != '/master' && steps.vars.outputs.tag != '/devel' }}
run: docker push cscfi/swift-sharing-request:${{steps.vars.outputs.tag}}
- name: Build the latest Docker image
if: ${{ steps.vars.outputs.tag == '/master' }}
run: docker build . --file Dockerfile --tag cscfi/swift-sharing-request:latest
- name: Push the latest Docker image
if: ${{ steps.vars.outputs.tag == '/master' }}
run: docker push cscfi/swift-sharing-request:latest
- name: Build the stage Docker image
if: ${{ steps.vars.outputs.tag == '/devel' }}
run: docker build . --file Dockerfile --tag cscfi/swift-sharing-request:stage
- name: Push the stage Docker image
if: ${{ steps.vars.outputs.tag == '/devel' }}
run: docker push cscfi/swift-sharing-request:stage
- name: Check out the repo
uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
DOCKER_IMAGE=cscfi/swift-sharing-request
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [[ $BRANCH == master ]]; then
VERSION=latest
elif [[ $BRANCH == devel ]]; then
VERSION=stage
fi
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=registry,ref=cscfi/swift-sharing-request:latest
cache-to: type=inline
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
4 changes: 2 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down

0 comments on commit 92183c6

Please sign in to comment.