Skip to content

Commit

Permalink
Add github actions CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
srisco committed Jun 16, 2020
1 parent ec30533 commit fabde91
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build

on:
push:
branches: master
release:

jobs:
buildx:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/[email protected]

- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=grycap/oscar
DOCKER_PLATFORMS=linux/amd64,linux/arm64
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
TAGS="--tag ${DOCKER_IMAGE}:latest"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:${VERSION}"
fi
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${VERSION} \
--build-arg GIT_COMMIT=${GITHUB_SHA::8} \
${TAGS} .
- name: Login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin

- name: Build and Push
run: docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}

- name: Clear
run: rm -f ${HOME}/.docker/config.json


0 comments on commit fabde91

Please sign in to comment.