Update GitHub Artifact Actions to v4 (major) #259
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 and deploy | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${symbol_dollar}{{ runner.os }}-maven-${symbol_dollar}{{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${symbol_dollar}{{ runner.os }}-maven- | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Build and Test | |
run: ./mvnw clean verify | |
- name: Code Quality | |
uses: codecov/codecov-action@v3 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: successful-build | |
retention-days: 5 | |
path: | | |
target | |
deployment | |
deploy: | |
if: github.event_name == 'push' | |
needs: [ 'build' ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: successful-build | |
- name: Deploy Documentation | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./target/generated-docs | |
- name: Run playbook | |
uses: dawidd6/action-ansible-playbook@v2 | |
with: | |
# Required, playbook filepath | |
playbook: playbook-application.yml | |
# Optional, directory where playbooks live | |
directory: ./deployment | |
# Optional, SSH private key | |
key: ${{secrets.SSH_KEY}} | |
# Optional, literal inventory file contents | |
inventory: | | |
[all] | |
${{secrets.SSH_HOST}} | |
# Optional, additional flags to pass to ansible-playbook | |
options: | | |
--inventory inventories/hosts | |
--user ${{secrets.SSH_USER}} | |
--limit ${{secrets.SSH_HOST}} | |
--extra-vars "ansible_user=${{secrets.SSH_USER}}" |