build #1496
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: build | |
on: | |
schedule: | |
- cron: "0 12 * * *" | |
push: | |
paths-ignore: | |
- "*.md" | |
- "*.txt" | |
- "*.png" | |
pull_request: | |
env: | |
IMAGE_NAME: atmoz/sftp | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # for proper signature verification | |
submodules: true # for shunit2 | |
- name: Run ShellCheck | |
uses: ludeeus/action-shellcheck@master | |
with: | |
ignore_paths: tests/shunit2 | |
- name: Build debian image | |
run: | | |
docker build . \ | |
--pull=true \ | |
--file=Dockerfile \ | |
--tag="$IMAGE_NAME:latest" \ | |
--tag="$IMAGE_NAME:debian" \ | |
--label="org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ | |
--label="org.opencontainers.image.revision=$GITHUB_SHA" \ | |
--label="org.opencontainers.image.created=$(date --rfc-3339=seconds)" | |
- name: Test debian image | |
run: tests/run $IMAGE_NAME:debian | |
- name: Build alpine image | |
run: | | |
docker build . \ | |
--pull=true \ | |
--file=Dockerfile-alpine \ | |
--tag="$IMAGE_NAME:alpine" \ | |
--label="org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ | |
--label="org.opencontainers.image.revision=$GITHUB_SHA" \ | |
--label="org.opencontainers.image.created=$(date --rfc-3339=seconds)" | |
- name: Test alpine image | |
run: tests/run $IMAGE_NAME:alpine | |
- name: Verify signature | |
if: github.ref == 'refs/heads/master' | |
uses: atmoz/git-verify-ref@master | |
with: | |
import-github-users: atmoz | |
- name: Push images to Docker Hub registry | |
if: github.ref == 'refs/heads/master' | |
run: | | |
echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login \ | |
-u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | |
docker push --all-tags $IMAGE_NAME | |
docker logout | |
- name: Push images to GitHub registry | |
if: github.ref == 'refs/heads/master' | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com \ | |
-u ${{ github.actor }} --password-stdin | |
TAG_DEBIAN=docker.pkg.github.com/$GITHUB_REPOSITORY/debian | |
TAG_ALPINE=docker.pkg.github.com/$GITHUB_REPOSITORY/alpine | |
docker tag $IMAGE_NAME:debian $TAG_DEBIAN | |
docker tag $IMAGE_NAME:alpine $TAG_ALPINE | |
docker push $TAG_DEBIAN | |
docker push $TAG_ALPINE | |
docker logout docker.pkg.github.com | |