feat: directly push to docker #3
Workflow file for this run
This file contains hidden or 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 and publish Docker | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags-ignore: | |
| - '*' | |
| workflow_dispatch: ~ | |
| env: | |
| REPO: linode/apl-nodejs-helloworld | |
| DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} | |
| BOT_EMAIL: ${{ vars.BOT_EMAIL }} | |
| BOT_USERNAME: ${{ vars.BOT_USERNAME }} | |
| COMMIT_SHA: ${{ github.sha }} | |
| jobs: | |
| build-test-cache: | |
| if: (!contains(github.event.head_commit.message, 'ci skip') && !startsWith(github.ref, 'refs/tags/') && !github.event.act) | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Set env | |
| run: | | |
| tag=${GITHUB_REF##*/} | |
| echo "Creating tag: $tag" | |
| echo "TAG=$tag" >> $GITHUB_ENV | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| revision=${{ env.COMMIT_SHA }} | |
| echo "Setting apps revision to: $revision" | |
| echo "APPS_REVISION=$revision" >> $GITHUB_ENV | |
| else | |
| echo "Leaving apps revision empty" | |
| fi | |
| git config --global user.email $BOT_EMAIL | |
| git config --global user.name $BOT_USERNAME | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REPO }} | |
| username: ${{ env.DOCKER_USERNAME }} | |
| password: '${{ env.DOCKER_PASSWORD }}' | |
| - name: CI tests, image build and push tag for main or branch | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| build-args: | | |
| APPS_REVISION=${{ env.APPS_REVISION }} | |
| context: . | |
| tags: | | |
| ${{ env.REPO }}:${{ env.TAG }} |