Files
wonderwall/.github/workflows/deploy.yml
2021-09-08 14:18:54 +02:00

48 lines
1.6 KiB
YAML

name: Build wonderwall
on: [push]
env:
image_base: ghcr.io/${{ github.repository }}
jobs:
build-and-deploy:
name: Build, push and deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Docker login
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: docker login ghcr.io -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
- name: Set version
run: |
echo "VERSION=$(./version.sh)" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker build . --tag ${{ env.image_base }}:${{ env.VERSION }} --tag ${{ env.image_base }}:latest
- name: Push versioned docker image
run: |
docker push ${{ env.image_base }}:${{ env.VERSION }}
- name: Push latest docker image
if: github.ref == 'refs/heads/master'
run: docker push ${{ env.image_base }}:latest
- name: Checkout nais-yaml
if: github.ref == 'refs/heads/master'
uses: actions/checkout@v2
with:
repository: navikt/nais-yaml
token: ${{ secrets.SRVNAIS_REPO_PUSH_PAT }}
path: nais-yaml
- name: Update nais-yaml
if: github.ref == 'refs/heads/master'
run: |
cd nais-yaml
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
sed -E -i "s#wonderwall_image:.+#wonderwall_image: ${{ env.image_base }}:${{ env.VERSION }}#" vars/global.yaml
git add .
git --no-pager diff --cached
git commit -a -m "Bump Wonderwall image version ${{ env.VERSION }}"
git push